/// <summary> /// Updates DFE files list view /// </summary> private void _RefreshIGEList() { //Checkboxes visibility igeListView.CheckBoxes = _IsSelectMode; igeListView.Items.Clear(); Collection <IGE> _EditorChallenges = new Collection <IGE>(); // Loading IGE tracks string profileFolder = string.Concat(LibraryConstants.GetSpecialFolder(LibraryConstants.TduSpecialFolder.Savegame), @"\", Program.ApplicationSettings.PlayerProfile); string igeFolder = string.Concat(profileFolder, LibraryConstants.FOLDER_IGE); if (Directory.Exists(igeFolder)) { FileInfo[] igeFiles = new DirectoryInfo(igeFolder).GetFiles(); foreach (FileInfo anotherTrack in igeFiles) { IGE newIge = TduFile.GetFile(anotherTrack.FullName) as IGE; if (newIge == null) { Log.Warning("Error when loading IGE track file: " + anotherTrack.FullName + ", skipping..."); } else { _EditorChallenges.Add(newIge); } } } // Filling editor tracks... int trackIndex = 1; foreach (IGE igeFile in _EditorChallenges) { // New list item ListViewItem lvi = new ListViewItem(trackIndex.ToString()) { Tag = igeFile }; // Track names lvi.SubItems.Add(igeFile.TrackName); lvi.SubItems.Add(igeFile.Description); lvi.SubItems.Add(igeFile.TrackId); igeListView.Items.Add(lvi); trackIndex++; } }
/// <summary> /// Returns the right TDUFile according to specified file. /// </summary> /// <param name="fileName">file name, without path</param> /// <returns>null if file is from an unsupported type</returns> public static TduFile GetFile(string fileName) { TduFile tduFile = new Regular(); FileInfo fi = new FileInfo(fileName); // New mapping management // Cameras if (Regex.IsMatch(fileName, Cameras.FILENAME_PATTERN, RegexOptions.IgnoreCase)) { if (fi.Exists) { tduFile = new Cameras(fileName); } else { tduFile = new Cameras(); } } // AIConfig else if (Regex.IsMatch(fileName, AIConfig.FILENAME_PATTERN, RegexOptions.IgnoreCase)) { if (fi.Exists) { tduFile = new AIConfig(fileName); } else { tduFile = new AIConfig(); } } // DB else if (Regex.IsMatch(fileName, DB.FILENAME_PATTERN, RegexOptions.IgnoreCase)) { if (fi.Exists) { tduFile = new DB(fileName); } else { tduFile = new DB(); } } // BNK else if (Regex.IsMatch(fileName, BNK.FILENAME_PATTERN, RegexOptions.IgnoreCase)) { tduFile = new BNK(fileName); } // DDS else if (Regex.IsMatch(fileName, DDS.FILENAME_PATTERN, RegexOptions.IgnoreCase)) { if (fi.Exists) { tduFile = new DDS(fileName); } else { tduFile = new DDS(); } } // 2DB else if (Regex.IsMatch(fileName, _2DB.FILENAME_PATTERN, RegexOptions.IgnoreCase) || Regex.IsMatch(fileName, _2DB.FILENAME_OLD_PATTERN, RegexOptions.IgnoreCase)) { if (fi.Exists) { tduFile = new _2DB(fileName); } else { tduFile = new _2DB(); } } // MAP else if (Regex.IsMatch(fileName, MAP.FILENAME_PATTERN, RegexOptions.IgnoreCase)) { if (fi.Exists) { tduFile = new MAP(fileName); } else { tduFile = new MAP(); } } // XMB else if (Regex.IsMatch(fileName, XMB.FILENAME_PATTERN, RegexOptions.IgnoreCase)) { if (fi.Exists) { tduFile = new XMB(fileName); } else { tduFile = new XMB(); } } // WAV + XMB_WAV else if (Regex.IsMatch(fileName, XMB_WAV.FILENAME_PATTERN, RegexOptions.IgnoreCase)) { try { if (fi.Exists) { tduFile = new XMB_WAV(fileName); } else { tduFile = new XMB_WAV(); } } catch (FormatException) { // standard WAV file } } // PCH else if (Regex.IsMatch(fileName, PCH.FILENAME_PATTERN, RegexOptions.IgnoreCase)) { tduFile = new PCH(fileName); } // DB Resources else if (Regex.IsMatch(fileName, DBResource.FILENAME_PATTERN, RegexOptions.IgnoreCase)) { if (fi.Exists) { tduFile = new DBResource(fileName); } else { tduFile = new DBResource(); } } // DFE else if (Regex.IsMatch(fileName, DFE.FILENAME_PATTERN, RegexOptions.IgnoreCase)) { tduFile = new DFE(fileName); } // IGE else if (Regex.IsMatch(fileName, IGE.FILENAME_PATTERN, RegexOptions.IgnoreCase)) { tduFile = new IGE(fileName); } // Regular by default else { tduFile = new Regular(); } // To update common information tduFile._FinalizeLoading(fileName); return(tduFile); }