Example #1
0
        private bool PrepareGameLaunch()
        {
            string sRootFolder = CApplicationSettings.Instance.GetValue(ESettingsStrings.RootPath).GetValueString();
            string sGameFolder = CApplicationSettings.Instance.GetValue(ESettingsStrings.GameFolderPath).GetValueString();

            // Check if game folder is not inside root folder
            if (CPathUtils.ExtractRelativeToRoot(sGameFolder) == sGameFolder)
            {
                MessageBoxResult res = MessageBox.Show(Properties.Resources.GameLauchCopyToRoot,
                                                       Properties.Resources.CommonNotice,
                                                       MessageBoxButton.OKCancel,
                                                       MessageBoxImage.Exclamation);

                if (res == MessageBoxResult.OK)
                {
                    string sFullTempDirPath = sRootFolder + "\\" + m_sGameTempDirName;
                    if (Directory.Exists(sFullTempDirPath))
                    {
                        Directory.Delete(sFullTempDirPath, true);
                    }

                    Directory.CreateDirectory(sFullTempDirPath);

                    CProcessUtils.CopyDirectory(sGameFolder, sFullTempDirPath);
                    SetGameFolderInSysCFG(sFullTempDirPath);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
Example #2
0
        /// <summary>
        /// Copies the startup files and starts the programs with their specified startups
        /// </summary>
        /// <param name="sFileSavePath">Path containing one filename, which will be used for all programs startups. If no file is specified, the defaults will be used</param>
        public void Start(string sFileSavePath)
        {
            string fileName  = "";
            string directory = "";
            int    lastDir   = sFileSavePath.LastIndexOf('\\');

            // Deduce the filename
            if (lastDir < sFileSavePath.Length - 1)
            {
                int dotPos  = sFileSavePath.LastIndexOf('.');
                int nameEnd = sFileSavePath.Length - 1;

                if (dotPos > lastDir)
                {
                    nameEnd = dotPos;
                }

                fileName = sFileSavePath.Substring(lastDir + 1, nameEnd - lastDir - 1);

                // Now construct directory path
                directory = sFileSavePath.Substring(0, lastDir);
            }
            // TODO: Account for no filename specified

            foreach (SDCCProgram program in Programs.Values)
            {
                foreach (SStartupFile file in program.StartupFiles.Values)
                {
                    string newFile = file.FullName;
                    if (file.Copy)
                    {
                        if (!Directory.Exists(directory))
                        {
                            Directory.CreateDirectory(directory);
                        }

                        newFile = directory + "\\" + fileName + "." + file.Extension;
                        CProcessUtils.CopyFile(file.FullName, newFile);
                        ExpandMacros(newFile);
                    }

                    if (file.LaunchWithProgram)
                    {
                        Process          proc = new Process();
                        ProcessStartInfo info = new ProcessStartInfo(program.ExecutablePath);
                        info.Arguments += newFile;
                        proc.StartInfo  = info;
                        proc.Start();
                    }
                }

                /*if (hasProgramInstanceOpen == false)
                 * {
                 *              Process proc = new Process();
                 *              ProcessStartInfo info = new ProcessStartInfo(program.ExecutablePath);
                 *              proc.StartInfo = info;
                 *              proc.Start();
                 * }*/
            }
        }
Example #3
0
        private bool ProcessRequest(FileInfo info)
        {
            string sNewFile = saveFileTextBox.Text + "\\" + info.Name;

            if (copyCheckbox.IsChecked == true)
            {
                if (CPathUtils.IsStringCEConform(saveFileTextBox.Text))
                {
                    CProcessUtils.CopyFile(info.FullName, sNewFile, false);
                }
                else
                {
                    return(false);
                }

                if (rcCheckbox.IsChecked == true)
                {
                    FileInfo newFile = new FileInfo(sNewFile);
                    CProcessUtils.RunRC(newFile);
                }
            }
            else
            {
                if (rcCheckbox.IsChecked == true)
                {
                    CProcessUtils.RunRC(info);
                }
            }

            return(true);
        }
Example #4
0
        static void OnContextRunRCClicked(object sender, RoutedEventArgs args)
        {
            DirectoryTreeItem selectedItem = m_targetTreeView.SelectedItem as DirectoryTreeItem;

            if (!selectedItem.IsDirectory)
            {
                FileInfo info = new FileInfo(selectedItem.FullPath);
                CProcessUtils.RunRC(info);
            }
        }
Example #5
0
        static void OnContextRunGFXClicked(object sender, RoutedEventArgs args)
        {
            DirectoryTreeItem selectedItem = m_targetTreeView.SelectedItem as DirectoryTreeItem;

            if (selectedItem.IsDirectory)
            {
                CUserInteractionUtils.ShowErrorMessageBox("You can only run the gfxexporter on files (directory was selected)");                 // LOCALIZE
                return;
            }
            else
            {
                FileInfo fileInf = new FileInfo(selectedItem.FullPath);

                if (fileInf.Extension != ".swf")
                {
                    CUserInteractionUtils.ShowErrorMessageBox("You can only run the gfxexporter on .swf files");                     // LOCALIZE
                    return;
                }

                CProcessUtils.RunGFXExporter(fileInf);
            }
        }
Example #6
0
        static void OnContextPasteClicked(object sender, EventArgs args)
        {
            // DONE_TODO: Implement directory copying
            if (!Clipboard.ContainsFileDropList())
            {
                return;
            }

            DirectoryTreeItem targetItem = m_targetTreeView.SelectedItem as DirectoryTreeItem;

            if (!targetItem.IsDirectory)
            {
                targetItem = targetItem.GetParentSave() as DirectoryTreeItem;
            }

            //string fileSource = Clipboard.GetFileDropList()[0];

            foreach (string fileSource in Clipboard.GetFileDropList())
            {
                FileInfo fileInfo = new FileInfo(fileSource);

                if (fileInfo.Exists)
                {
                    string fileTarget = targetItem.FullPath + "\\" + fileInfo.Name;

                    try
                    {
                        //File.Copy(fileSource, fileTarget, true);


                        if (m_bIsFileCut)
                        {
                            FileSystem.MoveFile(fileSource, fileTarget, UIOption.AllDialogs, UICancelOption.DoNothing);
                        }
                        else
                        {
                            CProcessUtils.CopyFile(fileSource, fileTarget, false);
                        }
                    }
                    catch (Exception e)
                    {
                        CUserInteractionUtils.ShowErrorMessageBox(e.Message);
                        m_bIsFileCut = false;
                    }
                }
                else
                {
                    // It's a direcory?
                    DirectoryInfo dirInf = new DirectoryInfo(fileSource);
                    if (dirInf.Exists)
                    {
                        string targetDir = targetItem.FullPath + "\\" + dirInf.Name;

                        if (m_bIsFileCut)
                        {
                            CProcessUtils.MoveDirectory(dirInf.FullName, targetDir, false);
                        }
                        else
                        {
                            CProcessUtils.CopyDirectory(dirInf.FullName, targetDir, false);
                        }
                    }
                }
            }

            TraverseDirectory(new DirectoryInfo(targetItem.FullPath), ref targetItem);
        }
Example #7
0
        public void ExportTrackingFile(string sSaveFilePath, EFileRoot root)
        {
            FileInfo dirinfo = new FileInfo(sSaveFilePath);

            /*if (Directory.Exists(dirinfo.DirectoryName))
             * {
             *      Directory.Delete(dirinfo.DirectoryName, true);
             *      Directory.CreateDirectory(dirinfo.DirectoryName);
             * }*/

            DumpFilesToDisk(sSaveFilePath, root);
            FileInfo trackingFile = new FileInfo(sSaveFilePath);


            string        sDestinationDir = trackingFile.DirectoryName;
            string        sSourceDir      = "";
            List <string> exportList;

            switch (root)
            {
            case EFileRoot.eFR_CERoot:
            {
                sSourceDir = CApplicationSettings.Instance.GetValue(ESettingsStrings.RootPath).GetValueString();
                exportList = m_trackedCERootFiles;
            }
            break;

            case EFileRoot.eFR_GameFolder:
            {
                sSourceDir = CApplicationSettings.Instance.GetValue(ESettingsStrings.GameFolderPath).GetValueString();
                exportList = m_trackedGameFolderFiles;
            }
            break;

            default:
                throw new Exception("Invalid value for EFileRoot");
            }

            bool bVerboseExport = CApplicationSettings.Instance.GetValue(ESettingsStrings.VerboseImportExport).GetValueBool();

            foreach (string relativePath in exportList)
            {
                string sTargetFilePath = sDestinationDir + relativePath;
                string sSourceFilePath = sSourceDir + relativePath;
                if (File.Exists(sTargetFilePath))
                {
                    FileInfo destinationInfo = new FileInfo(sTargetFilePath);
                    FileInfo sourceInfo      = new FileInfo(sSourceFilePath);

                    int compareResult = destinationInfo.LastWriteTime.CompareTo(sourceInfo.LastWriteTime);

                    if (compareResult > 0)
                    {
                        string message = String.Format("Destination file {0} is more recent than " +
                                                       "source file {1}, skipping export for it", sTargetFilePath,
                                                       sSourceFilePath);                                        // LOCALIZE
                        if (bVerboseExport)
                        {
                            CUserInteractionUtils.ShowInfoMessageBox(message);
                        }

                        message = String.Format("Destination file {0} is more recent than " +
                                                "source file {1}, skipping export for it", sTargetFilePath,
                                                sSourceFilePath);                                         // DONOTLOCALIZE

                        CLogfile.Instance.LogWarning("[Source tracker]" + message);
                        continue;
                    }
                    else if (compareResult == 0)
                    {
                        string message = String.Format("Source file {1} is not different " +
                                                       "from destination file {0}, skipping export for it", sTargetFilePath,
                                                       sSourceFilePath);                                         // LOCALIZE
                        if (bVerboseExport)
                        {
                            CUserInteractionUtils.ShowInfoMessageBox(message);
                        }

                        message = String.Format("Source file {1} is not different " +
                                                "from destination file {0}, skipping export for it", sTargetFilePath,
                                                sSourceFilePath);                                                // DONOTLOCALIZE
                        // Always log to file...
                        CLogfile.Instance.LogWarning("[Source tracker]" + message);
                        continue;
                    }
                }

                try
                {
                    FileInfo info = new FileInfo(sTargetFilePath);

                    if (!Directory.Exists(info.DirectoryName))
                    {
                        Directory.CreateDirectory(info.DirectoryName);
                    }
                    CProcessUtils.CopyFile(sSourceFilePath, sTargetFilePath);
                }
                catch (Exception e)
                {
                    string message = "Failed to export file! Error: " + e.Message;                     // LOCALIZE

                    CUserInteractionUtils.ShowErrorMessageBox(message);

                    message = "Failed to export file! Error: " + e.Message;                     // DONOTLOCALIZE
                    CLogfile.Instance.LogError(message);
                    return;
                }
            }

            string sLastExportFiles    = CApplicationSettings.Instance.GetValue(ESettingsStrings.LastExportFiles).GetValueString();
            string sNewLastExportFiles = "";

            char[] splitter = { ';' };

            string[] singleFiles = sLastExportFiles.Split(splitter, StringSplitOptions.RemoveEmptyEntries);

            // If there are two files then look for the obsolete one

            foreach (string lastSave in singleFiles)
            {
                if (sSaveFilePath != lastSave)
                {
                    sNewLastExportFiles += lastSave + ";";
                }
            }



            sNewLastExportFiles += sSaveFilePath + ";";

            CApplicationSettings.Instance.SetValue(new CSetting(ESettingsStrings.LastExportFiles,
                                                                sNewLastExportFiles));
        }
Example #8
0
        public void ImportTrackingList(string sFilePath, EFileRoot root)
        {
            Reset(root, false);

            LoadFileTrackingList(sFilePath, root);

            FileInfo trackingFileInfo = new FileInfo(sFilePath);

            string        sTrackingDir     = trackingFileInfo.DirectoryName;
            string        sDestinationRoot = "";
            List <string> importList;

            switch (root)
            {
            case EFileRoot.eFR_CERoot:
            {
                sDestinationRoot = CApplicationSettings.Instance.GetValue(ESettingsStrings.RootPath).GetValueString();
                importList       = m_trackedCERootFiles;
            } break;

            case EFileRoot.eFR_GameFolder:
            {
                sDestinationRoot = CApplicationSettings.Instance.GetValue(ESettingsStrings.GameFolderPath).GetValueString();
                importList       = m_trackedGameFolderFiles;
            } break;

            default:
                throw new Exception("Invalid value for EFileRoot");
            }

            CSetting verboseImport  = CApplicationSettings.Instance.GetValue(ESettingsStrings.VerboseImportExport);
            bool     bVerboseImport = verboseImport.GetValueBool();


            foreach (string relativePath in importList)
            {
                string sDestinationPath = sDestinationRoot + relativePath;
                string sSourcePath      = sTrackingDir + relativePath;

                FileInfo sourceFile = new FileInfo(sSourcePath);
                FileInfo targetFile = new FileInfo(sDestinationPath);


                int compareResult = sourceFile.LastWriteTime.CompareTo(targetFile.LastWriteTime);

                if (compareResult > 0)
                {
                    try
                    {
                        // Using CopyFile here too in case of large files
                        // DONE_TODO: see if this gets troublesome if file already exists
                        // Using custom function instead
                        CProcessUtils.CopyFile(sSourcePath, sDestinationPath, true);
                    }
                    catch (Exception)
                    {
                    }
                }
                else if (compareResult == 0)
                {
                    string message = String.Format("Source file {1} is not different " +
                                                   "from destination file {0}, skipping import for it", sDestinationPath,
                                                   sSourcePath);                                             // LOCALIZE
                    if (bVerboseImport)
                    {
                        CUserInteractionUtils.ShowInfoMessageBox(message);
                    }

                    message = String.Format("Source file {1} is not different " +
                                            "from destination file {0}, skipping import for it", sDestinationPath,
                                            sSourcePath);                                                    // DONOTLOCALIZE
                    // Always log to file...
                    CLogfile.Instance.LogWarning("[Source tracker]" + message);
                }
                else
                {
                    string message = String.Format("Destination file {0} is more recent than " +
                                                   "source file {1}, skipping import for it", sDestinationPath,
                                                   sSourcePath);                                             // LOCALIZE
                    if (bVerboseImport)
                    {
                        CUserInteractionUtils.ShowInfoMessageBox(message);
                    }
                    message = String.Format("Destination file {0} is more recent than " +
                                            "source file {1}, skipping import for it", sDestinationPath,
                                            sSourcePath);                                                     // DONOTLOCALIZE
                    // Always log to file...
                    CLogfile.Instance.LogWarning("[Source tracker]" + message);
                }
            }


            string sLastImportFiles    = CApplicationSettings.Instance.GetValue(ESettingsStrings.LastImportFiles).GetValueString();
            string sNewLastImportFiles = "";

            char[] splitter = { ';' };

            string[] singleFiles = sLastImportFiles.Split(splitter, StringSplitOptions.RemoveEmptyEntries);

            // If there are two files then look for the obsolete one

            foreach (string lastSave in singleFiles)
            {
                if (lastSave != m_sCurrentTrackingList)
                {
                    sNewLastImportFiles += lastSave + ";";
                }
            }


            m_sCurrentTrackingList = sFilePath;
            sNewLastImportFiles   += sFilePath;

            CApplicationSettings.Instance.SetValue(new CSetting(ESettingsStrings.LastImportFiles,
                                                                sNewLastImportFiles));
        }
Example #9
0
 private void CopyDirectory(DirectoryInfo info, string sTargetPath)
 {
     CProcessUtils.CopyDirectory(info.FullName, sTargetPath, false);
 }