Exemple #1
0
        /// <summary>
        /// Export specified track items
        /// </summary>
        /// <param name="trackItems"></param>
        /// <param name="packName"></param>
        /// <param name="targetFolder"></param>
        private static void _ExportTracks(IEnumerable <ListViewItem> trackItems, string packName, string targetFolder)
        {
            if (trackItems != null && !string.IsNullOrEmpty(packName) && !string.IsNullOrEmpty(targetFolder) && Directory.Exists(targetFolder))
            {
                // Directories
                string packFolder    = string.Concat(targetFolder, @"\", File2.GetValidFileName(packName, true));
                string tracksFolder  = string.Concat(packFolder, LibraryConstants.FOLDER_TRACKS);
                string defaultFolder = string.Concat(packFolder, LibraryConstants.FOLDER_DEFAULT);

                Directory.CreateDirectory(packFolder);
                Directory.CreateDirectory(tracksFolder);

                // Libraries
                string frameworkFileName = string.Concat(Tools.WorkingPath, DjeFramework1.LibraryProperties.FILE_LIBRARY);
                string tduLibFileName    = string.Concat(Tools.WorkingPath, TDUModdingLibrary.LibraryProperties.FILE_LIBRARY);

                File.Copy(frameworkFileName, string.Concat(packFolder, DjeFramework1.LibraryProperties.FILE_LIBRARY), true);
                File.Copy(tduLibFileName, string.Concat(packFolder, TDUModdingLibrary.LibraryProperties.FILE_LIBRARY), true);

                // EXE files
                string tpFileName = string.Concat(Tools.WorkingPath, LibraryConstants.FOLDER_TRACKS, AppConstants.FILE_EXE_TRACKPACK);

                File.Copy(tpFileName, string.Concat(packFolder, AppConstants.FILE_EXE_TRACKPACK), true);

                // Exported tracks
                foreach (ListViewItem anotherItem in trackItems)
                {
                    DFE customTrack = anotherItem.Tag as DFE;

                    if (customTrack != null)
                    {
                        FileInfo fi = new FileInfo(customTrack.FileName);
                        File.Copy(customTrack.FileName, string.Concat(tracksFolder, @"\", fi.Name), true);
                    }
                }

                // Default challenges
                File2.CopyDirectory(string.Concat(Tools.WorkingPath, LibraryConstants.FOLDER_XML, LibraryConstants.FOLDER_DEFAULT, LibraryConstants.FOLDER_CHALLENGES), defaultFolder);
            }
        }
Exemple #2
0
        /// <summary>
        /// Converts specified IGE challenges to DFE files
        /// </summary>
        /// <param name="igeFiles"></param>
        private static Couple <int> _ConvertIGEtoDFE(IGE[] igeFiles)
        {
            Couple <int> returnedCount = new Couple <int>(0, 0);

            if (igeFiles != null)
            {
                int totalCount   = igeFiles.Length;
                int successCount = 0;

                foreach (IGE anotherIGE in igeFiles)
                {
                    try
                    {
                        DFE convertedTrack = anotherIGE;

                        // New file name
                        string tracksFolder = AppConstants.FOLDER_TRACKS;
                        //string newFileName = new FileInfo(convertedTrack.FileName).Name;
                        string targetFileName = string.Concat(tracksFolder, @"\", DFE.FILE_DATA_DFE, File2.GetValidFileName(convertedTrack.TrackName, false)
                                                              /*File2.GetNameFromFilename(newFileName)*/);

                        convertedTrack.SaveAs(targetFileName);
                        successCount++;
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Unable to convert IGE track to DFE.", ex);
                    }
                }

                returnedCount = new Couple <int>(successCount, totalCount);
            }

            return(returnedCount);
        }