From b4d850bc0ca72ec42bac1dec09f1fc740026d7de Mon Sep 17 00:00:00 2001 From: yukieiji Date: Sat, 1 Feb 2025 15:21:29 +0900 Subject: [PATCH 1/3] feat:can dl multiple dll in release --- Dropship/DataManager.cs | 17 +++++++++++++---- Dropship/Objects/ModData.cs | 24 +++++++++--------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/Dropship/DataManager.cs b/Dropship/DataManager.cs index 88dd1b7..8d4b940 100644 --- a/Dropship/DataManager.cs +++ b/Dropship/DataManager.cs @@ -147,21 +147,25 @@ public static bool IsModDownloaded(string modName, string modVersion = null) public static async Task DownloadMod(string modName, string version, bool dependency = false) { - ModData mod = ModList[modName]; + if (!ModList.TryGetValue(modName, out var mod)) + { + return false; + } + string modFolderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "mods", $"{modName}"); try { Release releaseToDownload = null; if (version == "latest") { - string url = ModList[modName].ReleasesUrl + "/latest"; // link to the latest release + string url = mod.Releases + "/latest"; // link to the latest release var latestresponse = _HttpClient.GetAsync(url, HttpCompletionOption.ResponseContentRead).Result; releaseToDownload = await latestresponse.Content.ReadFromJsonAsync(); } else { // search for the tag with specified version - var searchresponse = _HttpClient.GetAsync(ModList[modName].ReleasesUrl, HttpCompletionOption.ResponseHeadersRead).Result; + var searchresponse = _HttpClient.GetAsync(mod.Releases, HttpCompletionOption.ResponseHeadersRead).Result; List releases = await searchresponse.Content.ReadFromJsonAsync>(); foreach (var release in releases) @@ -183,7 +187,12 @@ public static async Task DownloadMod(string modName, string version, bool ReleaseAsset assetToDownload = null; foreach (var asset in releaseToDownload.Assets) { - if (asset.FileName.EndsWith(".dll")) + var assetName = asset.FileName; + if (assetName.EndsWith(".dll") && + ( + string.IsNullOrEmpty(mod.DllName) || + mod.DllName == assetName.Replace(".dll", "") + )) { assetToDownload = asset; break; diff --git a/Dropship/Objects/ModData.cs b/Dropship/Objects/ModData.cs index 9f7116c..41409fa 100644 --- a/Dropship/Objects/ModData.cs +++ b/Dropship/Objects/ModData.cs @@ -2,22 +2,16 @@ namespace Dropship.Objects; -public class ModData +public record class ModData( + string Name, + string Author, + string Releases, // This is the github api link that are we getting releases from + Dictionary Dependencies, // All the mod's dependecies and their versions. Empty if none + Dictionary Versioning, // This list contains some predefined game versions for tags + string? DllName = null) { - [JsonPropertyName("Name")] - public string Name { get; set; } - - [JsonPropertyName("Author")] - public string Author { get; set; } - - [JsonPropertyName("Releases")] - public string ReleasesUrl { get; set; } // This is the github api link that are we getting releases from - - [JsonPropertyName("Dependencies")] - public Dictionary Dependencies { get; set; } // All the mod's dependecies and their versions. Empty if none - - [JsonPropertyName("Versioning")] - public Dictionary Versioning { get; set; } // This list contains some predefined game versions for tags + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public string? DllName { get; set; } = DllName; } public class ModList From 9f30ca9d066c385c269682e3d774c357732ab74d Mon Sep 17 00:00:00 2001 From: yukieiji Date: Sat, 1 Feb 2025 15:26:50 +0900 Subject: [PATCH 2/3] refactor:more --- Dropship/DataManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dropship/DataManager.cs b/Dropship/DataManager.cs index 8d4b940..22f1494 100644 --- a/Dropship/DataManager.cs +++ b/Dropship/DataManager.cs @@ -242,11 +242,11 @@ public static async Task DownloadMod(string modName, string version, bool contentStream.Close(); // Check for dependencies - if (ModList[modName].Dependencies.Count > 0 && !dependency) + if (mod.Dependencies.Count > 0 && !dependency) { Console.WriteLine("\nChecking for dependencies..."); - foreach (var d in ModList[modName].Dependencies) + foreach (var d in mod.Dependencies) { if (!IsModDownloaded(d.Value, d.Key)) { @@ -260,18 +260,18 @@ public static async Task DownloadMod(string modName, string version, bool if (!dependency) { Console.WriteLine($"\n{modName} successfully installed"); - if (ModList[modName].Versioning.ContainsKey(releaseToDownload.Version)) + if (mod.Versioning.ContainsKey(releaseToDownload.Version)) { if (DepotDownloader.IsVersionInstalled(releaseToDownload.Version)) { - Console.WriteLine($"Among Us {ModList[modName].Versioning[releaseToDownload.Version]} is specified for {modName} {releaseToDownload.Version}\nDownload it? [y/n]"); + Console.WriteLine($"Among Us {mod.Versioning[releaseToDownload.Version]} is specified for {modName} {releaseToDownload.Version}\nDownload it? [y/n]"); string input = Console.ReadLine(); if (!string.IsNullOrWhiteSpace(input)) { if (input.ToLower() == "y") { - string buildid = ManifestVersionsList[ModList[modName].Versioning[releaseToDownload.Version]]; - DepotDownloader.DownloadBuild(buildid, ModList[modName].Versioning[releaseToDownload.Version]); + string buildid = ManifestVersionsList[mod.Versioning[releaseToDownload.Version]]; + DepotDownloader.DownloadBuild(buildid, mod.Versioning[releaseToDownload.Version]); } } } From 7fdb544747c9c0c9457bd3b4c324a93fd8590c76 Mon Sep 17 00:00:00 2001 From: yukieiji Date: Sat, 1 Feb 2025 15:30:47 +0900 Subject: [PATCH 3/3] fea:ExR, ExS, EvE dl --- Dropship/Data/mods.json | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Dropship/Data/mods.json b/Dropship/Data/mods.json index 039bd4f..66726ad 100644 --- a/Dropship/Data/mods.json +++ b/Dropship/Data/mods.json @@ -115,6 +115,39 @@ "Versioning" : { "v2.2.1" : "2021.7.20e" } + }, + "ExtremeRoles": { + "Name": "Extreme Roles", + "Author": "yukieiji", + "Releases": "https://api.github.com/repos/yukieiji/ExtremeRoles/releases", + "Versioning": { + "v12.1.4.2": "2024.11.26" + }, + "DllName": "ExtremeRoles" + }, + "ExtremeSkins": { + "Name": "Extreme Skins", + "Author": "yukieiji", + "Releases": "https://api.github.com/repos/yukieiji/ExtremeRoles/releases", + "Dependencies": { + "ExtremeRoles": "v12.1.4.2" + }, + "Versioning": { + "v12.1.4.2": "2024.11.26" + }, + "DllName": "ExtremeSkins" + }, + "ExtremeVoiceEngine": { + "Name": "Extreme Voice Engine", + "Author": "yukieiji", + "Releases": "https://api.github.com/repos/yukieiji/ExtremeRoles/releases", + "Dependencies": { + "ExtremeRoles": "v12.1.4.2" + }, + "Versioning": { + "v12.1.4.2": "2024.11.26" + }, + "DllName": "ExtremeVoiceEngine" } } } \ No newline at end of file