private async void button_run_Click(object sender, EventArgs e) { var filePaths = Directory.GetFiles(textBox_srcPath.Text, "*.*", SearchOption.TopDirectoryOnly); var fileInfos = filePaths.Select(path => new FileInfo(path)); _progressforms.Show(); ClearProgress(); var algSelected = comboBox_algorithm.Text; if (comboBox_storage.Text == "MemoryStorage") { _storage = new MemoryStorage(); } else if (comboBox_storage.Text == "LocalStorage") { _storage = new LocalStorage(algSelected, _progressforms.UpdateProgress); } DeduplicateController deduCtrl = new DeduplicateController(algSelected, _storage, _progressforms.UpdateProgress); await Task.Run(() => { deduCtrl.ImportFiles(fileInfos); }); var storedFiles = _storage.GetAllFileViewModels().ToList(); var fvmGridSrc = storedFiles.Select(fvm => new { Name = fvm.Name, Size = GeneralExtension.SizeSuffix(fvm.Size), ChunkCount = fvm.Chunks.Count(), ProcessTime = $"{fvm.ProcessTime:hh\\:mm\\:ss\\:ms}" }).ToList();
private void DevTestMethod() { // developer sandbox debugging area GeneralExtension.ValidateDisplaySettings(this, this, true, true); return; ShowHelpForm(); return; var args = new string[] { "-u", "-input=D:\\Temp\\PeppaPig_p.psarc", "-x", "-d", "-f=Pc", "-v=RS2014", "-output=D:\\Temp", "-c" }; var cmdArgs = String.Join(" ", args); var appDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var cliPath = Path.Combine(appDir, "packer.exe"); if (File.Exists(cliPath)) { GeneralExtension.RunExternalExecutable(cliPath, arguments: cmdArgs); } else { MessageBox.Show("'Build, Rebuild Solution' while configuration is set to 'Debug w CLI'", "WRONG CONFIGURATION IS SELECTED ...", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void MainForm_Shown(object sender, EventArgs e) { // check for first run bool firstRun = ConfigRepository.Instance().GetBoolean("general_firstrun"); // confirm and log App.config was properly loaded at runtime var appConfigStatus = "<ERROR> Load Failed"; if (Convert.ToBoolean(ConfigurationManager.AppSettings["key"])) { appConfigStatus = "Load Successful"; } // validate and log runtime display setting var displaySettings = String.Empty; if (!GeneralExtension.ValidateDisplaySettings(this, this, false, firstRun)) { displaySettings = "\r\n - Adjusted AutoScaleDimensions, AutoScaleMode, and AutoSize"; } GlobalsConfig.Log.Info( String.Format(" - App.config Status ({0})\r\n ", appConfigStatus) + String.Format(" - System Display DPI Setting ({0})\r\n ", GeneralExtension.GetDisplayDpi(this)) + // validate and log runtime display setting String.Format(" - System Display Screen Scale Factor ({0}%) ", GeneralExtension.GetDisplayScalingFactor(this) * 100) + String.Format(displaySettings) ); // don't bug the Developers when in design mode ;) bool showRevNote = ConfigRepository.Instance().GetBoolean("general_showrevnote"); if (showRevNote && !GeneralExtension.IsInDesignMode) { ShowHelpForm(); ConfigRepository.Instance()["general_showrevnote"] = "false"; } // don't bug the Developers when in design mode ;) if (!firstRun || GeneralExtension.IsInDesignMode) { return; } this.Refresh(); MessageBox.Show(new Form { TopMost = true }, "Welcome to the Song Creator Toolkit for Rocksmith ..." + Environment.NewLine + "Commonly known as, 'the toolkit'." + Environment.NewLine + Environment.NewLine + "It looks like this may be your first time running the toolkit. " + Environment.NewLine + "Please fill in the Configuration menu with your selections.", "Song Creator Toolkit for Rocksmith - FIRST RUN", MessageBoxButtons.OK, MessageBoxIcon.Information); ShowConfigScreen(); BringToFront(); }
// only gets called one time public GeneralConfig() { InitializeComponent(); // fix readonly textbox/cuebox background colors general_rs1path.BackColor = SystemColors.Window; general_rs2014path.BackColor = SystemColors.Window; general_wwisepath.BackColor = SystemColors.Window; creator_defaulttone.BackColor = SystemColors.Window; creator_defaultproject.BackColor = SystemColors.Window; general_defaultauthor.Validating += ValidateSortName; loading = true; try { PopulateAppIdCombo(general_defaultappid_RS2012, GameVersion.RS2012); PopulateAppIdCombo(general_defaultappid_RS2014, GameVersion.RS2014); PopulateEnumCombo(general_defaultgameversion, typeof(GameVersion)); PopulateEnumCombo(general_defaultplatform, typeof(GamePlatform)); PopulateEnumCombo(converter_source, typeof(GamePlatform)); PopulateEnumCombo(converter_target, typeof(GamePlatform)); PopulateRampUp(); PopulateConfigDDC(); // CRITICAL - force static Wwise path and settings for Mac Mono/Wine packages on first run if ((Environment.OSVersion.Platform == PlatformID.MacOSX || GeneralExtension.IsWine()) && ConfigRepository.Instance().GetBoolean("general_firstrun")) { ConfigRepository.Instance()["general_autoupdate"] = "false"; ConfigRepository.Instance()["general_replacerepo"] = "true"; ConfigRepository.Instance()["general_defaultauthor"] = "CST_Mac"; ConfigRepository.Instance()["general_wwisepath"] = "C:\\Program Files (x86)\\Audiokinetic\\Wwise\\Authoring"; // interestingly the full path is not needed here ConfigRepository.Instance()["general_replacerepo"] = "false"; ConfigRepository.Instance()["general_defaultplatform"] = "Mac"; // TODO: identify these Mac paths if static (they are not static) ConfigRepository.Instance()["general_rs2014path"] = ""; ConfigRepository.Instance()["general_rs1path"] = ""; } LoadAndSetupConfiguration(this.Controls); } catch { /*For mono compatibility*/ } loading = false; }
public ToolkitInfo ExtractToolkitInfo() { var tkInfo = new ToolkitInfo(); var toolkitVersionEntry = _archive.TOC.FirstOrDefault(x => (x.Name.Equals("toolkit.version"))); if (toolkitVersionEntry != null) { _archive.InflateEntry(toolkitVersionEntry); toolkitVersionEntry.Data.Position = 0; tkInfo = GeneralExtension.GetToolkitInfo(new StreamReader(toolkitVersionEntry.Data)); } else { tkInfo.PackageAuthor = "Ubisoft"; } return(tkInfo); }
public ToolkitInfo ExtractToolkitInfo() { var tkInfo = new ToolkitInfo(); var toolkitVersionEntry = _archive.TOC.FirstOrDefault(x => (x.Name.Equals("toolkit.version"))); if (toolkitVersionEntry != null) { _archive.InflateEntry(toolkitVersionEntry); tkInfo = GeneralExtension.GetToolkitInfo(new StreamReader(toolkitVersionEntry.Data)); } else { // this helps prevent null exceptions tkInfo.ToolkitVersion = "Null"; tkInfo.PackageAuthor = "Ubisoft"; tkInfo.PackageVersion = "0"; tkInfo.PackageComment = "Null"; tkInfo.PackageRating = "5"; } return(tkInfo); }
/// <summary> /// Merge two xml repositories into one /// <para>see usage in AutoUpdater</para> /// </summary> /// <param name="sourceFile">XML source file</param> /// <param name="destinationFile">XML destination file</param> public void Merge(string sourceFile, string destinationFile) { // Load source repository FileName = sourceFile; List = Activator.CreateInstance <List <T> >(); Load(); var sourceRepoList = GeneralExtension.Copy(List); // Load destination repository FileName = destinationFile; List = Activator.CreateInstance <List <T> >(); Load(); // TODO: here is where xml with different elements do not merge // Merge source to destination (only if same elements) // List = List.Union(sourceRepoList, Comparer).ToList(); // TODO: so testing this code to see if it works with different elements // Merge source to destination (even if different elements) List = List.Union(sourceRepoList).ToList(); // Save Save(); }
private void bw_DoWork(object sender, DoWorkEventArgs e) { ProcessOutput = String.Empty; var rampPath = String.Empty; var cfgPath = String.Empty; this.Invoke(new MethodInvoker(() => { rampPath = GetRampUpMdl(); cfgPath = GetConfig(); })); var errorsFound = new StringBuilder(); var totalCount = FilesDb.Count; var currentCount = 0; var errorCount = 0; // TODO: change progress reporting method so it is responsive for a single file var step = (int)Math.Round(1.0 / FilesDb.Count * 100, 0); var progress = 0; bw.ReportProgress(progress); foreach (var file in FilesDb) { var consoleOutput = String.Empty; currentCount++; int count = currentCount; GeneralExtension.InvokeIfRequired(lblStatus, delegate { lblStatus.Text = String.Format("Processing file {0} of {1} ... Please wait.", count, totalCount); }); switch (Path.GetExtension(file.Value)) { case ".xml": // Arrangement DDCreator.ApplyDD(file.Value, (int)cmbPhraseLen.Value, chkRemoveSustains.Checked, rampPath, cfgPath, out consoleOutput, chkOverwrite.Checked, chkGenLogFile.Checked); break; case ".psarc": // PC / Mac (RS2014) case ".dat": // PC (RS1) case ".edat": // PS3 case "": // XBox 360 ApplyPackageDD(file.Value, (int)cmbPhraseLen.Value, chkRemoveSustains.Checked, rampPath, cfgPath, out consoleOutput, chkOverwrite.Checked, chkGenLogFile.Checked); break; } if (!String.IsNullOrEmpty(consoleOutput)) { errorsFound.AppendLine(consoleOutput); errorCount++; } progress += step; bw.ReportProgress(progress); } if (!String.IsNullOrEmpty(errorsFound.ToString())) { ProcessOutput = errorsFound.ToString(); } GeneralExtension.InvokeIfRequired(lblStatus, delegate { lblStatus.Text = String.Format("Sucessfully processed {0} of {1} files ...", totalCount - errorCount, totalCount); }); e.Result = errorCount; // No Errors = 0 }
private void inlayGenerateButton_Click(object sender, EventArgs e) { // put inlays in proper directory if (Directory.Exists(ConfigRepository.Instance()["general_rs2014path"])) { dlcSavePath = Path.Combine(ConfigRepository.Instance()["general_rs2014path"], "dlc", "Inlays"); } else { dlcSavePath = Path.Combine(workDir, "cgm", "dlc", "Inlays"); } if (!Directory.Exists(dlcSavePath)) { Directory.CreateDirectory(dlcSavePath); } using (var ofd = new SaveFileDialog()) { ofd.FileName = (InlayName.GetValidInlayName(Frets24).ToLower()).GetValidFileName(); ofd.Filter = "Custom Inlay DLC (*.*)|*.*"; 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 = GeneralExtension.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 OverwriteExistingPackage(); 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 btnInstall_Click(object sender, EventArgs e) { btnInstall.Enabled = false; // reset to display the revision note on next restart ConfigRepository.Instance()["general_showrevnote"] = "true"; var tempToolkitDir = Path.Combine(Path.GetTempPath(), "RocksmithToolkit"); var updaterAppPath = Path.Combine(LocalToolkitDir, APP_UPDATER); var updatingAppPath = Path.Combine(tempToolkitDir, APP_UPDATING); var updaterConfigPath = Path.Combine(LocalToolkitDir, APP_UPDATER + APP_CONFIG_EXT); var updatingConfigPath = Path.Combine(tempToolkitDir, APP_UPDATING + APP_CONFIG_EXT); if (!File.Exists(updaterAppPath)) { var errMsg = "Could not find file: " + APP_UPDATER + Environment.NewLine + "Please reinstall the toolkit manually."; BetterDialog2.ShowDialog(errMsg, "Toolkit Updater Error", null, null, "Ok", Bitmap.FromHicon(SystemIcons.Error.Handle), "Error", 150, 150); return; } // create temp process backup folder if (Directory.Exists(tempToolkitDir)) { Directory.Delete(tempToolkitDir, true); } Directory.CreateDirectory(tempToolkitDir); try { // make a copy of AutoUpdater to prevent locking the process during update File.Copy(updaterAppPath, updatingAppPath, true); File.Copy(updaterConfigPath, updatingConfigPath, true); // normal operation if (!GeneralExtension.IsInDesignMode) { // passing args for process and backup directories to RocksmithToolkitUpdating.exe (Primary Usage Mode) var cmdArgs = String.Format("\"{0}\" \"{1}\"", LocalToolkitDir, tempToolkitDir); try // different AutoUpdater shells for MacWine testing { GeneralExtension.RunExternalExecutable(updatingAppPath, arguments: cmdArgs); } catch (Exception ex) { // changed external process call for MacWine debugging MessageBox.Show("Report hit updater try #2 to the developers: " + Environment.NewLine + ex.Message); var startInfo = new ProcessStartInfo { FileName = updatingAppPath, Arguments = cmdArgs, UseShellExecute = false, CreateNoWindow = true, // hide command window }; using (var updater = new Process()) { updater.StartInfo = startInfo; updater.Start(); } } // Kill current toolkit process now that AutoUpdater process is started Environment.Exit(0); } else // allows updater to be run in design mode for developers { var args = new string[] { LocalToolkitDir, tempToolkitDir }; // args = new string[0]; // to debug CLI help using (var autoUpdater = new AutoUpdaterForm(args)) autoUpdater.Show(); } } catch (ObjectDisposedException) { /* Do nothing - user cancelled the download */ } catch (Exception ex) { var errMsg = "Could not run file: " + APP_UPDATING + Environment.NewLine + "Please reinstall the toolkit manually." + Environment.NewLine + ex.Message; BetterDialog2.ShowDialog(errMsg, "Toolkit Updater Error", null, null, "Ok", Bitmap.FromHicon(SystemIcons.Error.Handle), "Error", 150, 150); } btnInstall.Enabled = true; }
public void UpdateAppId(object sender, DoWorkEventArgs e) { var srcFilePaths = e.Argument as string[]; errorsFound = new StringBuilder(); var step = (int)Math.Round(1.0 / srcFilePaths.Length * 100, 0); int progress = 0; // show some initial progress if only one song if (step > 99) { progress = 50; } var tmpDir = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())).FullName; var appId = NewAppId; if (String.IsNullOrEmpty(appId)) { throw new InvalidDataException("<ERROR> AppID is null or empty ..."); } foreach (string srcFilePath in srcFilePaths) { Application.DoEvents(); var srcPlatform = srcFilePath.GetPlatform(); bwRepack.ReportProgress(progress, String.Format("Updating '{0}'", Path.GetFileName(srcFilePath))); if (!srcPlatform.IsConsole) { NoCloseStream dataStream = new NoCloseStream(); try { // use fast PsarcLoader memory methods (respect processing order/grouping) using (PSARC p = new PSARC(true)) { // write the new appid.appid using (var fs = File.OpenRead(srcFilePath)) p.Read(fs); dataStream = p.ReplaceData(x => x.Name.Equals("appid.appid"), appId); using (var fs = File.Create(srcFilePath)) p.Write(fs, true); // update toolkit.version var tkStream = p.GetData(x => x.Name.Equals("toolkit.version")); if (tkStream != null) { using (var tkReader = new StreamReader(tkStream)) { var tkInfo = GeneralExtension.GetToolkitInfo(tkReader); var packageComment = tkInfo.PackageComment; if (String.IsNullOrEmpty(packageComment)) { packageComment = TKI_APPID; } else if (!packageComment.Contains(TKI_APPID)) { packageComment = packageComment + " " + TKI_APPID; } var toolkitVersion = ToolkitVersion.RSTKGuiVersion; if (!tkInfo.ToolkitVersion.Contains(toolkitVersion)) { toolkitVersion = String.Format("{0} ({1})", toolkitVersion, tkInfo.ToolkitVersion); } using (var tkInfoStream = new MemoryStream()) { PackageCreator.GenerateToolkitVersion(tkInfoStream, tkInfo.PackageAuthor, tkInfo.PackageVersion, packageComment, tkInfo.PackageRating, toolkitVersion); PsarcExtensions.InjectArchiveEntry(srcFilePath, "toolkit.version", tkInfoStream); tkInfoStream.Dispose(); // CRITICAL } } } } } catch (Exception ex) { errorsFound.AppendLine(String.Format("Error trying repack file '{0}': {1}", Path.GetFileName(srcFilePath), ex.Message)); } if (dataStream != null) { dataStream.CloseEx(); } progress += step; bwRepack.ReportProgress(progress); } else { errorsFound.AppendLine(String.Format("File '{0}' is not a valid desktop platform package.", Path.GetFileName(srcFilePath))); } } bwRepack.ReportProgress(100); e.Result = "repack"; }
static void Main(string[] args) { // make the logger available globally in application ConfigGlobals.Log = LogManager.GetCurrentClassLogger(); // TODO: figure out way for native mac\linux OS var logPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "_RSToolkit_" + DateTime.Now.ToString("yyyy-MM-dd") + ".log"); // verify external apps in 'tools' and 'ddc' directory ExternalApps.VerifyExternalApps(); // throws necessary exception if missing // workaround fix for Win10 NET4.6 compatiblity issue var updaterVersion = "Null"; try { updaterVersion = ToolkitVersion.RSTKUpdaterVersion(); } catch (Exception e) { MessageBox.Show(e.Message + "\n\n" + e.ToString()); /* DO NOTHING */ } ConfigGlobals.Log.Info(//OSVersion on unix will return it's Kernel version, urgh. String.Format("RocksmithToolkitGUI: v{0}\r\n ", ToolkitVersion.RSTKGuiVersion) + String.Format("RocksmithToolkitLib: v{0}\r\n ", ToolkitVersion.RSTKLibVersion()) + String.Format("RocksmithToolkitUpdater: v{0}\r\n ", updaterVersion) + String.Format("Dynamic Difficulty Creator: v{0}\r\n ", FileVersionInfo.GetVersionInfo(Path.Combine(ExternalApps.TOOLKIT_ROOT, ExternalApps.APP_DDC)).ProductVersion) + String.Format("OS: {0} ({1} bit)\r\n ", Environment.OSVersion, Environment.Is64BitOperatingSystem ? "64" : "32") + String.Format(".NET Framework Runtime: v{0}\r\n ", Environment.Version) + String.Format("JIT: {0}\r\n ", JitVersionInfo.GetJitVersion()) + String.Format("WINE_INSTALLED: {0}\r\n ", GeneralExtension.IsWine()) + String.Format("MacOSX: {0}\r\n ", Environment.OSVersion.Platform == PlatformID.MacOSX) ); if (!Environment.Version.ToString().Contains("4.0.30319") && ConfigRepository.Instance().GetBoolean("general_firstrun")) { var envMsg = "The toolkit runs best with .NET 4.0.30319 installed." + Environment.NewLine + "You are currently running .NET " + Environment.Version.ToString() + Environment.NewLine + "Install the correct version if you experinece problems running the toolkit. " + Environment.NewLine + Environment.NewLine + "Click 'Yes' to download and install the correct version now from:" + Environment.NewLine + "https://www.microsoft.com/en-us/download/confirmation.aspx?id=17718"; if (MessageBox.Show(envMsg, "Incorrect .NET Version ...", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { Process.Start("https://www.microsoft.com/en-us/download/confirmation.aspx?id=17718"); Thread.Sleep(500); Process.Start("https://www.howtogeek.com/118869/how-to-easily-install-previous-versions-of-the-.net-framework-in-windows-8"); // Kill current toolkit process now that download process is started Environment.Exit(0); } } Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); AppDomain.CurrentDomain.UnhandledException += (s, e) => { var exception = e.ExceptionObject as Exception; ConfigGlobals.Log.Error(exception, "\n{0}\n{1}\nException cached:\n{2}\n\n", exception.Source, exception.TargetSite, exception.InnerException); //Log.Error("Application Stdout:\n\n{0}", new StreamReader(_stdout.ToString()).ReadToEnd()); if (MessageBox.Show(String.Format("Application.ThreadException met.\n\n\"{0}\"\n\n{1}\n\nPlease send us \"{2}\", open log file now?", exception.ToString(), exception.Message.ToString(), Path.GetFileName(logPath)), "Unhandled Exception", MessageBoxButtons.YesNo) == DialogResult.Yes) { //figure out how to call it single time //Process.Start("explorer.exe", string.Format("/select,\"{0}\"", logPath)); Process.Start(logPath); } //Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true }); //write back to Stdout in console could use custom streamwriter so you could write to console from there }; // UI thread exceptions handling. Application.ThreadException += (s, e) => { var exception = e.Exception; ConfigGlobals.Log.Error(exception, "\n{0}\n{1}\nException cached:\n{2}\n\n", exception.Source, exception.TargetSite, exception.InnerException); //Log.Error("Application Stdout:\n\n{0}", new StreamReader(_stdout.ToString()).ReadToEnd()); if (MessageBox.Show(String.Format("Application.ThreadException met.\n\n\"{0}\"\n\n{1}\n\nPlease send us \"{2}\", open log file now?", exception.ToString(), exception.Message.ToString(), Path.GetFileName(logPath)), "Thread Exception", MessageBoxButtons.YesNo) == DialogResult.Yes) { //Process.Start("explorer.exe", string.Format("/select,\"{0}\"", logPath)); Process.Start(logPath); } }; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm(args)); }
static void Main(string[] args) { // make the logger available globally in application GlobalsConfig.Log = LogManager.GetCurrentClassLogger(); // TODO: figure out way for native mac\linux OS var logPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "_RSToolkit_" + DateTime.Now.ToString("yyyy-MM-dd") + ".log"); // verify external apps in 'tools' and 'ddc' directory ExternalApps.VerifyExternalApps(); // throws necessary exception if missing // workaround fix for Win10 NET4.6 compatiblity issue var updaterVersion = "Null"; try { updaterVersion = ToolkitVersion.RSTKUpdaterVersion(); } catch (Exception e) { MessageBox.Show(e.Message + "\n\n" + e.ToString()); /* DO NOTHING */ } var assembly = Assembly.LoadFile(typeof(RocksmithToolkitLib.ToolkitVersion).Assembly.Location); var assemblyConfiguration = assembly.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false).Cast <AssemblyConfigurationAttribute>().FirstOrDefault().Configuration.ToString() ?? ""; var dtuLib = DateTime.Parse(assemblyConfiguration, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal); GlobalsConfig.Log.Info(//OSVersion on unix will return it's Kernel version, urgh. String.Format(" - RocksmithToolkitGUI: v{0}\r\n ", ToolkitVersion.RSTKGuiVersion) + String.Format(" - RocksmithToolkitLib: v{0} [{1}]\r\n ", ToolkitVersion.RSTKLibVersion(), dtuLib) + String.Format(" - RocksmithToolkitUpdater: v{0}\r\n ", updaterVersion) + String.Format(" - Dynamic Difficulty Creator: v{0}\r\n ", FileVersionInfo.GetVersionInfo(Path.Combine(ExternalApps.TOOLKIT_ROOT, ExternalApps.APP_DDC)).ProductVersion) + String.Format(" - OS: {0} ({1} bit)\r\n ", Environment.OSVersion, Environment.Is64BitOperatingSystem ? "64" : "32") + String.Format(" - .NET Framework Runtime: v{0}\r\n ", Environment.Version) + String.Format(" - CultureInfo: ({0}) \r\n ", CultureInfo.CurrentCulture.ToString()) + String.Format(" - Current Local DateTime: [{0}]\r\n ", DateTime.Now.ToString()) + String.Format(" - Current UTC DateTime: [{0}]\r\n ", DateTime.UtcNow.ToString()) + String.Format(" - JIT: {0}\r\n ", JitVersionInfo.GetJitVersion()) + String.Format(" - WINE_INSTALLED: {0}\r\n ", GeneralExtension.IsWine()) + String.Format(" - MacOSX: {0} ", Environment.OSVersion.Platform == PlatformID.MacOSX) ); if (!Environment.Version.ToString().Contains("4.0.30319") && ConfigRepository.Instance().GetBoolean("general_firstrun")) { var envMsg = "The toolkit runs best with .NET 4.0.30319 installed." + Environment.NewLine + "You are currently running .NET " + Environment.Version.ToString() + Environment.NewLine + "Install the correct version if you experinece problems running the toolkit. " + Environment.NewLine + Environment.NewLine + "Click 'Yes' to download and install the correct version now from:" + Environment.NewLine + "https://www.microsoft.com/en-us/download/confirmation.aspx?id=17718"; if (MessageBox.Show(envMsg, "Incorrect .NET Version ...", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { Process.Start("https://www.microsoft.com/en-us/download/confirmation.aspx?id=17718"); Thread.Sleep(500); Process.Start("https://www.howtogeek.com/118869/how-to-easily-install-previous-versions-of-the-.net-framework-in-windows-8"); // Kill current toolkit process now that download process is started Environment.Exit(0); } } // use custom event handlers if (!GeneralExtension.IsInDesignMode) { Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); AppDomain.CurrentDomain.UnhandledException += (s, e) => { var exception = e.ExceptionObject as Exception; GlobalsConfig.Log.Error(" - Unhandled.Exception:\n\nSource: {0}\nTarget: {1}\n{2}", exception.Source, exception.TargetSite, exception.ToString()); if (MessageBox.Show(String.Format("Unhandled.Exception:\n\n{0}\nPlease send us the {1} file if you need help. Open log file now?", exception.Message.ToString(), Path.GetFileName(logPath)), "Please Read This Important Message Completely ...", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { Process.Start(logPath); } GlobalExtension.HideProgress(); }; // UI thread exceptions handling. Application.ThreadException += (s, e) => { var exception = e.Exception; var packerErrMsg = RocksmithToolkitLib.DLCPackage.Packer.ErrMsg.ToString(); if (String.IsNullOrEmpty(packerErrMsg)) { GlobalsConfig.Log.Error(" - Application.ThreadException\n\nSource: {0}\nTarget: {1}\n{2}", exception.Source, exception.TargetSite, exception.ToString()); } else { GlobalsConfig.Log.Error(" - Application.ThreadException\n\nSource: {0}\nTarget: {1}\n{2}\n\nPacker.ThreadException (Corrupt CDLC): {3}", exception.Source, exception.TargetSite, exception.ToString(), packerErrMsg.Trim()); } if (exception.Message != null && exception.Message.Contains("expired")) { MessageBox.Show(String.Format("Activation.ThreadException:\n\n{0}", exception.Message), "Please Read This Important Message Completely ...", MessageBoxButtons.OK, MessageBoxIcon.Warning); Application.Exit(); } else { var exMessage = String.IsNullOrEmpty(packerErrMsg) ? exception.Message : String.Format("{0}\nPacker.ThreadException (Corrupt CDLC):\n{1}\n", exception.Message, packerErrMsg.Trim()); if (MessageBox.Show(String.Format("Application.ThreadException:\n\n{0}\n\nPlease send us the {1} file if you need help. Open log file now?", exMessage, Path.GetFileName(logPath)), "Please Read This Important Message Completely ...", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { Process.Start(logPath); } } GlobalExtension.HideProgress(); }; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm(args)); }
private static DLCPackageData ConvertAlbumArt(string cdlcFilePath, DLCPackageData info) { var unpackedDirPath = Path.Combine(Path.GetDirectoryName(cdlcFilePath), String.Format("{0}_Pc", Path.GetFileNameWithoutExtension(cdlcFilePath))); //D:\Temp\Test\RS001SONG0000005_Pc\MoreThanAFeeling\GRAssets\AlbumArt // iterate through unpacked cdlc folder and find artwork var ddsFilesPath = Directory.GetFiles(unpackedDirPath, "*.dds", SearchOption.AllDirectories); if (!ddsFilesPath.Any()) { Console.WriteLine(@"Using default album artwork"); Console.ReadLine(); return(info); } try { var albumArtPath = ddsFilesPath[0]; Console.WriteLine(@"Converting album artwork using: " + Path.GetFileName(albumArtPath)); var ddsFiles = new List <DDSConvertedFile>(); ddsFiles.Add(new DDSConvertedFile() { sizeX = 64, sizeY = 64, sourceFile = albumArtPath, destinationFile = GeneralExtension.GetTempFileName(".dds") }); ddsFiles.Add(new DDSConvertedFile() { sizeX = 128, sizeY = 128, sourceFile = albumArtPath, destinationFile = GeneralExtension.GetTempFileName(".dds") }); ddsFiles.Add(new DDSConvertedFile() { sizeX = 256, sizeY = 256, sourceFile = albumArtPath, destinationFile = GeneralExtension.GetTempFileName(".dds") }); // Convert to correct dds file sizes DLCPackageCreator.ToDDS(ddsFiles); var albumArtDir = Path.GetDirectoryName(albumArtPath); var albumArtName = String.Format("album_{0}", info.Name.ToLower().Replace("_", "").GetValidFileName()); var ddsPartialPath = Path.Combine(albumArtDir, albumArtName); foreach (var dds in ddsFiles) { var destAlbumArtPath = String.Format("{0}_{1}.dds", ddsPartialPath, dds.sizeX); if (!File.Exists(dds.destinationFile)) { Console.WriteLine(@"Could not convert: " + destAlbumArtPath); } File.Copy(dds.destinationFile, destAlbumArtPath); // delete temp artwork file File.Delete(dds.destinationFile); dds.destinationFile = destAlbumArtPath; } // update package info with album art files info.ArtFiles = ddsFiles; } catch (Exception ex) { Console.WriteLine(@"Could not convert album artwork in " + Path.GetFileName(cdlcFilePath) + @": " + ex.Message); } return(info); }
private static void CheckAlbumArt(string srcDir, string dlcName) { // iterate through unpacked cdlc src folder and find artwork var ddsFilesPath = Directory.GetFiles(srcDir, "album_*.dds", SearchOption.AllDirectories); if (!ddsFilesPath.Any()) { Console.WriteLine(@"Did not find any album artwork in:" + Environment.NewLine + srcDir); Console.WriteLine(""); Console.ReadLine(); } try { bool is64 = false, is128 = false, is256 = false; string albumArtPath = String.Empty; foreach (var ddsFile in ddsFilesPath) { if (ddsFile.Contains("_64")) { is64 = true; } if (ddsFile.Contains("_128")) { is128 = true; } if (ddsFile.Contains("_256")) { is256 = true; albumArtPath = ddsFile; } } // do not update psarc if album artwork if already valid if (is64 && is128 && is256) { Console.WriteLine(@"Artwork is valid."); Console.WriteLine(""); return; } if (String.IsNullOrEmpty(albumArtPath)) { albumArtPath = ddsFilesPath[0]; } Console.WriteLine(@"Repairing album artwork using: " + Path.GetFileName(albumArtPath)); var ddsFiles = new List <DDSConvertedFile>(); if (!albumArtPath.Contains("_64")) { ddsFiles.Add(new DDSConvertedFile() { sizeX = 64, sizeY = 64, sourceFile = albumArtPath, destinationFile = GeneralExtension.GetTempFileName(".dds") }); } if (!albumArtPath.Contains("_128")) { ddsFiles.Add(new DDSConvertedFile() { sizeX = 128, sizeY = 128, sourceFile = albumArtPath, destinationFile = GeneralExtension.GetTempFileName(".dds") }); } if (!albumArtPath.Contains("_256")) { ddsFiles.Add(new DDSConvertedFile() { sizeX = 256, sizeY = 256, sourceFile = albumArtPath, destinationFile = GeneralExtension.GetTempFileName(".dds") }); } // Convert to correct dds file sizes DLCPackageCreator.ToDDS(ddsFiles); var albumArtDir = Path.GetDirectoryName(albumArtPath); var albumArtName = String.Format("album_{0}", dlcName.ToLower().Replace("_", "").GetValidFileName()); var ddsPartialPath = Path.Combine(albumArtDir, albumArtName); foreach (var dds in ddsFiles) { var destAlbumArtPath = String.Format("{0}_{1}.dds", ddsPartialPath, dds.sizeX); if (!File.Exists(dds.destinationFile)) { Console.WriteLine(@"Could not repair: " + destAlbumArtPath); } File.Copy(dds.destinationFile, destAlbumArtPath); // delete temp artwork file File.Delete(dds.destinationFile); } } catch (Exception ex) { Console.WriteLine("Exception: " + ex.Message); Console.ReadLine(); } }