public static void RefreshVersionsList(ref ModManager Instance, bool fullRefresh = false) { if (fullRefresh) { InstalledVersions.Clear(); Instance.VersionsListView.Items.Clear(); DirectoryInfo directoryInfo = new DirectoryInfo(Management.ProgramPaths.Sonic3AIR_MM_VersionsFolder); var folders = directoryInfo.GetDirectories().ToList(); if (folders.Count != 0) { foreach (var folder in folders.VersionSort().Reverse()) { string filePath = Path.Combine(folder.FullName, "sonic3air_game", "Sonic3AIR.exe"); if (File.Exists(filePath)) { VersionReader.AIRVersionData data = VersionReader.GetVersionData(Path.GetDirectoryName(filePath), false); Instance.VersionsListView.Items.Add(new AIRVersionListItem(data.ToString(), folder.FullName, (filePath == ProgramPaths.Sonic3AIRPath ? true : false))); InstalledVersions.Add(data); } } } } bool enabled = Instance.VersionsListView.SelectedItem != null; Instance.removeVersionButton.IsEnabled = enabled; Instance.selectVersionButton.IsEnabled = enabled; Instance.openVersionLocationButton.IsEnabled = enabled; }
public static MenuItem GenerateInstalledVersionsToolstripItem(DirectoryInfo folder, string filepath, ref ModManager Instance) { MenuItem item = new MenuItem(); item.Header = $"{folder.Name} ({VersionReader.GetVersionData(folder.FullName).ToString()})"; item.Tag = new VersionTag(Instance, filepath); item.Click += ChangeAIRPathByInstalls; item.IsCheckable = false; item.IsChecked = (filepath == Management.ProgramPaths.Sonic3AIRPath); return(item); }
public static void InstallVersionFromZIP() { OpenFileDialog ofd = new OpenFileDialog() { Filter = $"{Program.LanguageResource.GetString("SonicAIRVersionZIP")} (*.zip)|*.zip", Title = Program.LanguageResource.GetString("SelectSonicAIRVersionZIP") }; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { string destination = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Sonic3AIR_MM\\downloads"; string output = destination; using (var archive = SharpCompress.Archives.Zip.ZipArchive.Open(ofd.FileName)) { foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory)) { entry.WriteToDirectory(output, new ExtractionOptions() { ExtractFullPath = true, Overwrite = true }); } } string exe = Directory.GetFiles(destination, "Sonic3AIR.exe", SearchOption.AllDirectories).FirstOrDefault(); if (exe != null && exe != "") { VersionReader.AIRVersionData version_data = VersionReader.GetVersionData(output, true); string folder_path = $"{Management.ProgramPaths.Sonic3AIR_MM_VersionsFolder}\\{version_data.ToString()}"; MoveVersionToFinalLocation(destination, folder_path); } else { //TODO : Proper Message Implemented string message = ""; MessageBox.Show(message); CleanUpDownloadsFolder(); } } catch (Exception ex) { MessageBox.Show(ex.Message); CleanUpDownloadsFolder(); } } }
public static void RefreshVersionsList() { InstalledVersions.Clear(); DirectoryInfo directoryInfo = new DirectoryInfo(Management.ProgramPaths.Sonic3AIR_MM_VersionsFolder); var folders = directoryInfo.GetDirectories().ToList(); if (folders.Count != 0) { foreach (var folder in folders.VersionSort().Reverse()) { string filePath = Path.Combine(folder.FullName, "sonic3air_game", "Sonic3AIR.exe"); if (File.Exists(filePath)) { VersionReader.AIRVersionData data = VersionReader.GetVersionData(Path.GetDirectoryName(filePath), false); InstalledVersions.Add(data); } } } }