/// <summary>
        /// Convert ogg or wave audio files to Wwise 2013 wem audio, including preview wem file.
        /// </summary>
        /// <param name="audioPath"></param>
        /// <param name="audioQuality"></param>
        /// <param name="previewLength"></param>
        /// <param name="chorusTime"></param>
        /// <returns>wemPath</returns>
        public static string Convert2Wem(string audioPath, int audioQuality = 4, long previewLength = 30000, long chorusTime = 4000)
        {
            // TODO: check for converted wem's from GUI call and ask if we want generate over or use existing files.
            var audioPathNoExt = Path.Combine(Path.GetDirectoryName(audioPath), Path.GetFileNameWithoutExtension(audioPath));
            var oggPath        = String.Format(audioPathNoExt + ".ogg");
            var wavPath        = String.Format(audioPathNoExt + ".wav");
            var wemPath        = String.Format(audioPathNoExt + ".wem");
            var oggPreviewPath = String.Format(audioPathNoExt + "_preview.ogg");
            var wavPreviewPath = String.Format(audioPathNoExt + "_preview.wav");
            var wemPreviewPath = String.Format(audioPathNoExt + "_preview.wem");

            //switch to verify headers instead, maybe Plus current implmentation bugged as for me.
            if (audioPath.Substring(audioPath.Length - 4).ToLower() == ".ogg") //in RS1 ogg was actually wwise
            {
                // create ogg preview if it does not exist
                if (!File.Exists(oggPreviewPath))
                {
                    ExternalApps.Ogg2Preview(audioPath, oggPreviewPath, previewLength, chorusTime);
                }

                // convert ogg to wav
                ExternalApps.Ogg2Wav(audioPath, wavPath); //detect quality here
                ExternalApps.Ogg2Wav(oggPreviewPath, wavPreviewPath);
                audioPath = wavPath;
            }

            if (audioPath.Substring(audioPath.Length - 4).ToLower() == ".wav")
            {
                if (!File.Exists(wavPreviewPath))
                {
                    // may cause issues if you've got another guitar.ogg in folder, but it's extremely rare.
                    if (!File.Exists(oggPath))
                    {
                        ExternalApps.Wav2Ogg(audioPath, oggPath, audioQuality); // 4
                    }
                    // create preview from ogg and then convert back to wav
                    ExternalApps.Ogg2Preview(oggPath, oggPreviewPath, previewLength, chorusTime);
                    ExternalApps.Ogg2Wav(oggPreviewPath, wavPreviewPath);
                }

                Wwise.Wav2Wem(audioPath, wemPath, audioQuality);
                audioPath = wemPath;
            }

            if (audioPath.Substring(audioPath.Length - 4).ToLower() == ".wem" && !File.Exists(wemPreviewPath))
            {
                Revorb(audioPath, oggPath, WwiseVersion.Wwise2013);
                ExternalApps.Ogg2Wav(oggPath, wavPath);
                ExternalApps.Ogg2Preview(oggPath, oggPreviewPath, previewLength, chorusTime);
                ExternalApps.Ogg2Wav(oggPreviewPath, wavPreviewPath);
                Wwise.Wav2Wem(wavPath, wemPath, audioQuality);
                audioPath = wemPath;
            }

            return(audioPath);
        }
        public AppOverlayViewModel(UserSettings settings, IDialogManager dialogManager)
        {
            DisplayName    = "External Apps";
            _userSettings  = settings;
            _dialogManager = dialogManager;

            this.SetCommand(x => x.AddAppCommand).RegisterAsyncTask(AddApp).Subscribe();
            this.SetCommand(x => x.RemoveAppCommand).Subscribe(x => RemoveApp((ExternalApp)x));

            ExternalApps.EnableCollectionSynchronization(_externalAppsLock);
        }
Esempio n. 3
0
        private void UpdateStatic()
        {
            // unpack static.psarc
            const int numSteps = 5; // max number of times ReportProgress will be called
            var       step     = (int)Math.Round(1.0 / (numSteps + 2) * 100, 0);
            var       progress = 0;

            progress += step;
            ProcessStarted(progress, "Unpacking static file ... ");

            var srcPath  = Path.Combine(rsDir, "static.psarc");
            var destPath = Path.Combine(rsDir, "static.psarc.org");

            // backup the original static.psarc and never overwrite it
            if (!File.Exists(destPath))
            {
                File.Copy(srcPath, destPath, false);
            }

            var tmpModDir = Path.Combine(tmpWorkDir, "cis_static");

            if (Directory.Exists(tmpModDir))
            {
                DirectoryExtension.SafeDelete(tmpModDir, true);
            }
            Directory.CreateDirectory(tmpModDir);

            destPath = tmpModDir;
            // Packer.Unpack(srcPath, destPath); // not working here
            ExternalApps.UnpackPsarc(srcPath, destPath, DLCInlayCreator.GlobalTitlePlatform);

            // convert user png images to dds images
            progress += step * 3;
            ProcessStarted(progress, "Convertng user PNG images ...");

            // CRITICAL PATH AND ARGS
            var rootDir = string.Format("static_{0}", DLCInlayCreator.GlobalTitlePlatform);

            srcPath  = imageArray[6, 3];
            destPath = Path.Combine(tmpModDir, rootDir, "gfxassets\\views", Path.GetFileName(imageArray[6, 2]));
            ExternalApps.Png2Dds(srcPath, destPath, ImageHandler.Size2IntX(imageArray[6, 1]), ImageHandler.Size2IntY(imageArray[6, 1]));

            // repack static.psarc
            progress += step;
            ProcessStarted(progress, "Repacking static file ...");
            srcPath  = Path.Combine(tmpModDir, rootDir);
            destPath = Path.Combine(rsDir, "static.psarc");
            // Packer.Pack(srcPath, destPath);  // not working
            ExternalApps.RepackPsarc(srcPath, destPath, DLCInlayCreator.GlobalTitlePlatform);

            ProcessCompleted(null, null);
        }
 public static void Convert2Wem(string sourcePath, string destinationPath, int audioQuality)
 {
     try
     {
         LoadWwiseTemplate(sourcePath, audioQuality);
         ExternalApps.Wav2Wem(GetWwisePath());
         GetWwiseFiles(destinationPath);
     }
     catch (Exception ex)
     {
         //overrided ex, can't get real ex/msg, use log + throw;
         throw new Exception("Wwise audio file conversion failed: " + ex.Message);
     }
 }
        /// <summary>
        /// Convert ogg or wave audio files to Wwise 2013 wem audio, including preview wem file.
        /// </summary>
        /// <param name="audioPath"></param>
        /// <param name="audioQuality"></param>
        /// <param name="previewLength"></param>
        /// <param name="chorusTime"></param>
        /// <returns>wemPath</returns>
        public static string Convert2Wem(string audioPath, int audioQuality = 4, long previewLength = 30000, long chorusTime = 4000)
        {
            // ExternalApps.VerifyExternalApps(); // for testing
            var audioPathNoExt = Path.Combine(Path.GetDirectoryName(audioPath), Path.GetFileNameWithoutExtension(audioPath));
            var oggPath        = String.Format(audioPathNoExt + ".ogg");
            var wavPath        = String.Format(audioPathNoExt + ".wav");
            var wemPath        = String.Format(audioPathNoExt + ".wem");
            var oggPreviewPath = String.Format(audioPathNoExt + "_preview.ogg");
            var wavPreviewPath = String.Format(audioPathNoExt + "_preview.wav");
            var wemPreviewPath = String.Format(audioPathNoExt + "_preview.wem");

            if (audioPath.Substring(audioPath.Length - 4).ToLower() == ".ogg") //in RS1 ogg was actually wwise
            {
                ExternalApps.Ogg2Wav(audioPath, wavPath);                      //detect quality here
                if (!File.Exists(oggPreviewPath))
                {
                    ExternalApps.Ogg2Preview(audioPath, oggPreviewPath, previewLength, chorusTime);
                    ExternalApps.Ogg2Wav(oggPreviewPath, wavPreviewPath);
                }
                audioPath = wavPath;
            }

            if (audioPath.Substring(audioPath.Length - 4).ToLower() == ".wav")
            {
                if (!File.Exists(wavPreviewPath))
                {
                    if (!File.Exists(oggPath))
                    {
                        //may cause issues if you've got another guitar.ogg in folder, but it's extremely rare.
                        ExternalApps.Wav2Ogg(audioPath, oggPath, audioQuality); // 4
                    }
                    ExternalApps.Ogg2Preview(oggPath, oggPreviewPath, previewLength, chorusTime);
                    ExternalApps.Ogg2Wav(oggPreviewPath, wavPreviewPath);
                }
                Wwise.Convert2Wem(audioPath, wemPath, audioQuality);
                audioPath = wemPath;
            }

            if (audioPath.Substring(audioPath.Length - 4).ToLower() == ".wem" && !File.Exists(wemPreviewPath))
            {
                Revorb(audioPath, oggPath, Path.GetDirectoryName(Application.ExecutablePath), WwiseVersion.Wwise2013);
                ExternalApps.Ogg2Wav(oggPath, wavPath);
                ExternalApps.Ogg2Preview(oggPath, oggPreviewPath, previewLength, chorusTime);
                ExternalApps.Ogg2Wav(oggPreviewPath, wavPreviewPath);
                Wwise.Convert2Wem(wavPath, wemPath, audioQuality);
                audioPath = wemPath;
            }

            return(audioPath);
        }
Esempio n. 6
0
        private void SaveImages(object sender, DoWorkEventArgs e)
        {
            // method using Background Worker to report progress
            var       savePath = e.Argument as string;
            const int numSteps = 7; // max number of times progress change is reported
            var       step     = (int)Math.Round(1.0 / (numSteps + 2) * 100, 0);
            var       progress = 0;

            // Create temp folder for zipping files
            var tmpZipDir = Path.Combine(tmpWorkDir, "cis_zip");

            if (Directory.Exists(tmpZipDir))
            {
                DirectoryExtension.SafeDelete(tmpZipDir, true);
            }
            Directory.CreateDirectory(tmpZipDir);

            // convert user png images to dds images
            for (int i = 0; i < imageArray.GetUpperBound(0); i++)
            {
                progress += step;
                bwSaveImages.ReportProgress(progress, "Converting user PNG images ... " + i.ToString());

                if (imageArray[i, 3] != null) // user has specified a replacement image
                {
                    // CRITICAL PATH AND ARGS
                    var srcPath  = imageArray[i, 3];
                    var destPath = Path.Combine(tmpZipDir, Path.GetFileName(imageArray[i, 2]));
                    ExternalApps.Png2Dds(srcPath, destPath, ImageHandler.Size2IntX(imageArray[i, 1]), ImageHandler.Size2IntY(imageArray[i, 1]));
                }
            }
            progress += step;
            bwSaveImages.ReportProgress(progress, "Saving Intro Screens Template file ... ");

            // Write ini file setup.smb
            var           iniFile = Path.Combine(tmpZipDir, "setup.smb");
            Configuration iniCFG  = new Configuration();

            iniCFG["General"].Add(new Setting("author", String.IsNullOrEmpty(txtAuthor.Text) ? "CSC" : txtAuthor.Text));
            iniCFG["General"].Add(new Setting("seqname", String.IsNullOrEmpty(txtSeqName.Text) ? "SystemSaved" : txtSeqName.Text));
            iniCFG["General"].Add(new Setting("cscvers", ToolkitVersion.version));
            iniCFG["General"].Add(new Setting("modified", DateTime.Now.ToShortDateString()));
            iniCFG.Save(iniFile);

            // Zip intro sequence *.cis file
            ExternalApps.InjectZip(tmpZipDir, savePath, false, true);
        }
Esempio n. 7
0
        private static DLCPackageData ConvertAudio(DLCPackageData info)
        {
            var audioPath = info.OggPath;

            Console.WriteLine(@"Converting audio using: " + Path.GetFileName(audioPath));
            var audioPathNoExt   = Path.Combine(Path.GetDirectoryName(audioPath), Path.GetFileNameWithoutExtension(audioPath));
            var oggPath          = String.Format(audioPathNoExt + ".ogg");
            var wavPath          = String.Format(audioPathNoExt + ".wav");
            var wemPath          = String.Format(audioPathNoExt + ".wem");
            var oggPreviewPath   = String.Format(audioPathNoExt + "_preview.ogg");
            var wavPreviewPath   = String.Format(audioPathNoExt + "_preview.wav");
            var wemPreviewPath   = String.Format(audioPathNoExt + "_preview.wem");
            var audioPreviewPath = wemPreviewPath;

            //RS1 old ogg was actually wwise
            if (audioPath.Substring(audioPath.Length - 4).ToLower() == ".ogg")
            {
                ExternalApps.Ogg2Wav(audioPath, wavPath);
                if (!File.Exists(oggPreviewPath))
                {
                    ExternalApps.Ogg2Preview(audioPath, oggPreviewPath);
                    ExternalApps.Ogg2Wav(oggPreviewPath, wavPreviewPath);
                }
                audioPath = wavPath;
            }

            if (audioPath.Substring(audioPath.Length - 4).ToLower() == ".wav")
            {
                if (!File.Exists(wavPreviewPath))
                {
                    ExternalApps.Wav2Ogg(audioPath, oggPath, 4);
                    ExternalApps.Ogg2Preview(oggPath, oggPreviewPath);
                    ExternalApps.Ogg2Wav(oggPreviewPath, wavPreviewPath);
                }
                Wwise.Convert2Wem(audioPath, wemPath, 4); // default audio quality = 4
                audioPath = wemPath;
            }

            info.OggPath        = audioPath;
            info.OggPreviewPath = audioPreviewPath;

            return(info);
        }
        /// <summary>
        /// Covert Wav to Wem using WwiseCLI.exe
        /// for faster conversion, source path should be wav file
        /// </summary>
        /// <param name="wavSourcePath"></param>
        /// <param name="destinationPath"></param>
        /// <param name="audioQuality"></param>
        public static void Convert2Wem(string wavSourcePath, string destinationPath, int audioQuality)
        {
            try
            {
                var wwiseCLIPath     = GetWwisePath();
                var wwiseTemplateDir = LoadWwiseTemplate(wavSourcePath, audioQuality, wwiseCLIPath);

                // used to debug library paths
                // MessageBox.Show("wwiseCLIPath:" + wwiseCLIPath + Environment.NewLine + "wwiseTemplateDir: " + wwiseTemplateDir);

                ExternalApps.Wav2Wem(wwiseCLIPath, wwiseTemplateDir);
                GetWwiseFiles(destinationPath, wwiseTemplateDir);
            }
            catch (Exception ex)
            {
                //overridden ex, can't get real ex/msg, use log + throw;
                throw new Exception("Wwise audio file conversion failed: " + ex.Message);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Covert Wav to Wem using WwiseCLI.exe
        /// for faster conversion, source path should be wav file
        /// </summary>
        /// <param name="wavSourcePath"></param>
        /// <param name="destinationPath"></param>
        /// <param name="audioQuality"></param>
        public static void Wav2Wem(string wavSourcePath, string destinationPath, int audioQuality)
        {
            try
            {
                var wwiseCLIPath     = GetWwisePath();
                var wwiseTemplateDir = LoadWwiseTemplate(wavSourcePath, audioQuality);

                // console writes may be captured by starting toolkit in a command window an redirecting the output to a file
                // e.g., ‘RocksmithToolkitGUI.exe >console.log’
                Console.WriteLine("WwiseCLI:\n\'" + wwiseCLIPath + "\'\n\nTemplate:\n\'" + wwiseTemplateDir + "\'");

                ExternalApps.Wav2Wem(wwiseCLIPath, wwiseTemplateDir);
                GetWwiseFiles(destinationPath, wwiseTemplateDir);
            }
            catch (Exception ex)
            {
                //overridden ex, can't get real ex/msg, use log + throw;
                throw new Exception("Wwise audio file conversion failed: " + ex.Message);
            }
        }
Esempio n. 10
0
        public MainForm(string[] args)
        {
            // load order is important
            InitializeComponent();

            var ci     = new CultureInfo("en-US");
            var thread = Thread.CurrentThread;

            Application.CurrentCulture = thread.CurrentCulture = thread.CurrentUICulture = ci;
            //Application.CurrentInputLanguage = InputLanguage.FromCulture(ci); //may cause issues for non us cultures esp on wineMAC build got report of such issue.

            // it is better to be hidden initially and then unhide when needed
            if (GeneralExtensions.IsInDesignMode)
            {
                btnDevTestMethod.Visible = true;
            }

            // verify external apps in 'tools' and 'ddc' directory
            ExternalApps.VerifyExternalApps();

            InitMainForm();
        }
        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.GetValidInlayName(Frets24)) + "_" + StringExtensions.GetValidAcronym(Author) + ".cgm".GetValidFileName();

                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))
            {
                IOExtension.DeleteDirectory(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.RSTKGuiVersion.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))
            {
                IOExtension.DeleteDirectory(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);
            }
        }
        private void LoadCGM(string customCGM)
        {
            if (!String.IsNullOrEmpty(customCGM))
            {
                // Unpack CGM file (7z file format)
                var unpackedFolder = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(customCGM));

                if (Directory.Exists(unpackedFolder))
                {
                    IOExtension.DeleteDirectory(unpackedFolder);
                }

                ExternalApps.ExtractZip(customCGM, unpackedFolder);

                var errorMessage = string.Format("Template {0} can't be loaded, maybe doesn't exists or is corrupted.", customCGM);
                if (!Directory.Exists(unpackedFolder))
                {
                    MessageBox.Show(errorMessage, MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // Setup inlay pre-definition
                Frets24Checkbox.Checked = ColoredCheckbox.Checked = chkFlipX.Checked = chkFlipY.Checked = false;

                // Open the setup.smb INI file
                Configuration iniConfig = Configuration.LoadFromFile(Path.Combine(unpackedFolder, "setup.smb"));

                // switch to new sharpconfig.dll ini file format with [General] section
                // allow for backward compatibility with old *.cgm files
                try
                {
                    Author    = iniConfig["General"]["author"].Value;
                    InlayName = iniConfig["General"]["inlayname"].Value;
                    Frets24   = iniConfig["General"]["24frets"].GetValue <bool>();
                    Colored   = iniConfig["General"]["colored"].GetValue <bool>();
                }
                catch
                {
                    Author    = iniConfig["Setup"]["creatorname"].Value;
                    InlayName = iniConfig["Setup"]["guitarname"].Value;
                    try
                    {
                        // skip exception for templates created with old v2.0.0.71b
                        Frets24 = iniConfig["Setup"]["24frets"].GetValue <bool>();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception: Incomplete INI file - " + e.Message);
                    }
                    Colored = iniConfig["Setup"]["coloredinlay"].GetValue <bool>();
                }

                // Convert the dds files to png
                var iconFile = Path.Combine(unpackedFolder, "icon.dds");
                ExternalApps.Dds2Png(iconFile);
                var inlayFile = Path.Combine(unpackedFolder, "inlay.dds");
                ExternalApps.Dds2Png(inlayFile);

                if (!File.Exists(iconFile) || !File.Exists(inlayFile))
                {
                    MessageBox.Show(errorMessage, MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // Load png into picBoxes and save paths
                picIcon.ImageLocation  = IconFile = Path.ChangeExtension(iconFile, ".png");
                picInlay.ImageLocation = InlayFile = Path.ChangeExtension(inlayFile, ".png");
            }
        }
 private void FlipY_Changed(object sender, EventArgs e)
 {
     ExternalApps.PngFlipY(InlayFile);
     picInlay.ImageLocation = InlayFile;
 }
Esempio n. 14
0
                public static void Show(Type WindowType,
                                        PortScanMode PortScanMode = PortScanMode.Normal)
                {
                    try
                    {
                        switch (WindowType)
                        {
                            case Type.About:
                                if (aboutForm == null || aboutPanel == null | aboutPanel.VisibleState==DockState.Unknown)
                                {
                                    aboutForm = new About(aboutPanel);
                                    aboutPanel = aboutForm;
                                    aboutForm.Show(frmMain.Default.pnlDock);
                                }
                                else
                                {
                                    aboutPanel.Focus();
                                    aboutPanel.Show();
                                    aboutPanel.BringToFront();
                                    aboutForm.Focus();
                                }
                                
                                break;
                            case Type.ADImport:
                                adimportForm = new ADImport(adimportPanel);
                                adimportPanel = adimportForm;
                                adimportPanel.Show(frmMain.Default.pnlDock);
                                break;
                            case Type.Options:
                                optionsForm = new frmOptions(optionsPanel);
                                optionsForm.Show(frmMain.Default.pnlDock);
                                break;
                            case Type.SaveAs:
                                saveasForm = new SaveAs(saveasPanel);
                                saveasPanel = saveasForm;
                                saveasForm.Show(frmMain.Default.pnlDock);
                                break;
                            case Type.SSHTransfer:
                                sshtransferForm = new SSHTransfer(sshtransferPanel);
                                sshtransferPanel = sshtransferForm;
                                sshtransferForm.Show(frmMain.Default.pnlDock);
                                break;
                            case Type.Update:
                                if (updateForm == null || updatePanel == null || updatePanel.VisibleState == DockState.Unknown)
                                {
                                    updateForm = new UI.Window.Update(updatePanel);
                                    updatePanel = updateForm;
                                    updateForm.Show(frmMain.Default.pnlDock);
                                }
                                else
                                {
                                    updatePanel.Focus();
                                    updatePanel.Show();
                                    updatePanel.BringToFront();
                                    updateForm.Focus();
                                }
                                break;
                            case Type.Help:
                                helpForm = new Help(helpPanel);
                                helpPanel = helpForm;
                                helpForm.Show(frmMain.Default.pnlDock);
                                break;
                            case Type.ExternalApps:
                                if (externalappsForm == null || externalappsPanel == null || externalappsPanel.VisibleState == DockState.Unknown)
                                {
                                    externalappsForm = new ExternalApps(externalappsPanel);
                                    externalappsPanel = externalappsForm;
                                    externalappsForm.Show(frmMain.Default.pnlDock);
                                }
                                else
                                {
                                    externalappsPanel.Focus();
                                    externalappsPanel.Show();
                                    externalappsPanel.BringToFront();
                                    externalappsForm.Focus();
                                }
                                break;
                            case Type.PortScan:
                                portscanForm = new PortScan(portscanPanel, PortScanMode);
                                portscanPanel = portscanForm;
                                portscanForm.Show(frmMain.Default.pnlDock);
                                break;
                            case Type.UltraVNCSC:
                                ultravncscForm = new UltraVNCSC(ultravncscPanel);
                                ultravncscPanel = ultravncscForm;
                                ultravncscForm.Show(frmMain.Default.pnlDock);
                                break;
                            case Type.ComponentsCheck:
                                if (componentscheckForm == null || componentscheckPanel == null || componentscheckPanel.VisibleState == DockState.Unknown)
                                {
                                    componentscheckForm = new ComponentsCheck(componentscheckPanel);
                                    componentscheckPanel = componentscheckForm;
                                    componentscheckForm.Show(frmMain.Default.pnlDock);
                                }
                                else
                                {
                                    componentscheckPanel.Focus();
                                    componentscheckPanel.Show();
                                    componentscheckPanel.BringToFront();
                                    componentscheckForm.Focus();
                                }

                                break;
                            case Type.Announcement:
                                AnnouncementForm = new UI.Window.Announcement(AnnouncementPanel);
                                AnnouncementPanel = AnnouncementForm;
                                AnnouncementForm.Show(frmMain.Default.pnlDock);
                                break;
                            case Type.ConnectionStatus:
                                connectionStatusForm = new ConnectionStatusForm();
                                componentscheckPanel = connectionStatusForm;
                                connectionStatusForm.Show(frmMain.Default.pnlDock);
                                break;
                            case Type.QuickText:

                                if (quicktextPanel != null && (quicktextForm == null || quicktextPanel == null | quicktextPanel.VisibleState == DockState.Unknown))
                                {
                                    quicktextForm = new QuickTextEdit(quicktextPanel);
                                    quicktextPanel = quicktextForm;
                                    quicktextForm.Show(frmMain.Default.pnlDock);
                                }
                                else
                                {
                                    quicktextPanel.Focus();
                                    quicktextPanel.Show();
                                    quicktextPanel.BringToFront();
                                    quicktextForm.Focus();
                                }
                                
                                break;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageCollector.AddMessage(MessageClass.ErrorMsg,
                                                    (string)
                                                    ("Show (Runtime.Windows) failed" +
                                                     Constants.vbNewLine + ex.Message), true);
                    }
                }
Esempio n. 15
0
        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));
        }
Esempio n. 16
0
        private void UpdateCache()
        {
            // unpack cache.psarc
            const int numSteps = 8; // max number of times ReportProgress will be called
            var       step     = (int)Math.Round(1.0 / (numSteps + 2) * 100, 0);
            int       progress = 0;

            progress += step;
            ProcessStarted(progress, "Unpacking cache file ... ");

            var srcPath  = Path.Combine(rsDir, "cache.psarc");
            var destPath = Path.Combine(rsDir, "cache.psarc.org");

            // backup the original cache.psarc and never overwrite it
            if (!File.Exists(destPath))
            {
                File.Copy(srcPath, destPath, false);
            }

            var tmpCisDir = Path.Combine(tmpWorkDir, "cis_cache");

            if (Directory.Exists(tmpCisDir))
            {
                DirectoryExtension.SafeDelete(tmpCisDir, true);
            }
            // CRITCAL PATH
            Directory.CreateDirectory(Path.Combine(tmpCisDir, "cache4\\gfxassets\\views"));
            destPath = tmpCisDir;
            Packer.Unpack(srcPath, destPath);
            // ExternalApps.UnpackPsarc(srcPath, destPath, DLCInlayCreator.GlobalTitlePlatform);

            // convert user png images to dds images
            for (int i = 0; i < 5; i++)
            {
                progress += step;
                ProcessStarted(progress, "Convertng user PNG images ...");

                if (imageArray[i, 3] != null) // user has specified a replacement image
                {
                    // CRITICAL PATH AND ARGS
                    srcPath  = imageArray[i, 3];
                    destPath = Path.Combine(tmpCisDir, "cache4\\gfxassets\\views", Path.GetFileName(imageArray[i, 2]));
                    ExternalApps.Png2Dds(srcPath, destPath, ImageHandler.Size2IntX(imageArray[i, 1]), ImageHandler.Size2IntY(imageArray[i, 1]));
                }
            }

            // update user images to zip file
            progress += step;
            ProcessStarted(progress, "Injecting user images ...");
            // SUPER CRITICAL PATH AND ARGS
            var rootDir = string.Format("cache_{0}", DLCInlayCreator.GlobalTitlePlatform);

            srcPath  = Path.Combine(tmpCisDir, "cache4\\gfxassets");
            destPath = Path.Combine(tmpCisDir, rootDir, "cache4.7z");
            ExternalApps.InjectZip(srcPath, destPath, true);

            // repack cache.psarc
            progress += step;
            ProcessStarted(progress, "Repacking cache file ...");
            srcPath  = Path.Combine(tmpCisDir, rootDir);
            destPath = Path.Combine(rsDir, "cache.psarc");
            Packer.Pack(srcPath, destPath);
            // ExternalApps.RepackPsarc(srcPath, destPath, DLCInlayCreator.GlobalTitlePlatform);

            ProcessCompleted(null, null);
        }
Esempio n. 17
0
        public void TestVerifyExternalApps()
        {
            var results = ExternalApps.VerifyExternalApps();

            Assert.IsTrue(results);
        }
Esempio n. 18
0
        private void LoadImages(string cisPath)
        {
            // init image array and clear pics
            InitImageArray();
            InitImagePics();
            if (!File.Exists(cisPath))
            {
                return;
            }

            // background worker does not work with this method because it updates the
            // form/controls, so using alternate method to report progress
            const int numSteps = 7; // max number of times progress change is reported
            var       step     = (int)Math.Round(1.0 / (numSteps + 2) * 100, 0);
            var       progress = 10;

            ProcessStarted(progress, "Loading images from Intro Screens Template file ...");

            // create temp folder for unzipping *.cis file
            var tmpUnzipDir = Path.Combine(tmpWorkDir, "cis_unzip");

            if (Directory.Exists(tmpUnzipDir))
            {
                DirectoryExtension.SafeDelete(tmpUnzipDir, true);
            }
            if (!Directory.Exists(tmpUnzipDir))
            {
                Directory.CreateDirectory(tmpUnzipDir);
            }

            var srcPath  = cisPath;
            var destPath = tmpUnzipDir;

            ExternalApps.ExtractZip(srcPath, destPath);

            // Open the setup.smb INI file
            Configuration iniConfig = Configuration.LoadFromFile(Path.Combine(tmpUnzipDir, "setup.smb"));

            txtAuthor.Text       = iniConfig["General"]["author"].Value;
            txtSeqName.Text      = iniConfig["General"]["seqname"].Value;
            txtAuthor.ForeColor  = Color.Black;
            txtSeqName.ForeColor = Color.Black;

            // Convert the dds files to png
            IEnumerable <string> ismList = Directory.EnumerateFiles(tmpUnzipDir, "*.dds");

            foreach (string imagePath in ismList)
            {
                progress += step;
                ProcessStarted(progress, "Converting images to PNG files ... " + progress);

                ExternalApps.Dds2Png(imagePath);
                for (int i = 0; i < imageArray.GetUpperBound(0); i++)
                {
                    if (Path.GetFileName(imageArray[i, 2]) == Path.GetFileName(imagePath))
                    {
                        // Load user image paths and png into picBoxes
                        imageArray[i, 3] = Path.ChangeExtension(imagePath, ".png");
                        switch (Path.GetFileName(imagePath))
                        {
                        case "introsequence_i15.dds":
                            picBackground.ImageLocation = imageArray[i, 3];
                            lblBackground.Visible       = false;
                            break;

                        case "introsequence_i11.dds":
                            picCredits.ImageLocation = imageArray[i, 3];
                            lblCredits.Visible       = false;
                            break;

                        case "ubisoft_logo.png.dds":
                            picUbi.ImageLocation = imageArray[i, 3];
                            lblUbi.Visible       = false;
                            break;

                        case "gamebryo_logo.png.dds":
                            picLightspeed.ImageLocation = imageArray[i, 3];
                            lblLightspeed.Visible       = false;
                            break;

                        case "intro_studio_logos.png.dds":
                            picPedals.ImageLocation = imageArray[i, 3];
                            lblPedals.Visible       = false;
                            break;

                        case "rocksmith_2014_logo.dds":
                            picTitle.ImageLocation = imageArray[i, 3];
                            lblTitle.Visible       = false;
                            break;
                        }
                    }
                }
            }
            ProcessCompleted(null, null);
        }
        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));
        }