diff --git a/FetchDependencies/FetchDependencies.cs b/FetchDependencies/FetchDependencies.cs index 6217999..293645b 100644 --- a/FetchDependencies/FetchDependencies.cs +++ b/FetchDependencies/FetchDependencies.cs @@ -4,14 +4,21 @@ namespace FetchDependencies; public class FetchDependencies { + private const string VersionUrlGlobal = "https://www.iinact.com/updater/version"; + private const string VersionUrlChinese = "https://cninact.diemoe.net/CN解析/版本.txt"; + private const string PluginUrlGlobal = "https://www.iinact.com/updater/download"; + private const string PluginUrlChinese = "https://cninact.diemoe.net/CN解析/FFXIV_ACT_Plugin.dll"; + private Version PluginVersion { get; } private string DependenciesDir { get; } + private bool IsChinese { get; } private HttpClient HttpClient { get; } - public FetchDependencies(Version version, string assemblyDir, HttpClient httpClient) + public FetchDependencies(Version version, string assemblyDir, bool isChinese, HttpClient httpClient) { PluginVersion = version; DependenciesDir = assemblyDir; + IsChinese = isChinese; HttpClient = httpClient; } @@ -23,22 +30,25 @@ public void GetFfxivPlugin() if (!NeedsUpdate(pluginPath)) return; - if (!File.Exists(pluginZipPath)) - DownloadPlugin(pluginZipPath); - - try - { - ZipFile.ExtractToDirectory(pluginZipPath, DependenciesDir, true); - } - catch (InvalidDataException) + if (IsChinese) + DownloadFile(PluginUrlChinese, pluginPath); + else { + if (!File.Exists(pluginZipPath)) + DownloadFile(PluginUrlGlobal, pluginZipPath); + try + { + ZipFile.ExtractToDirectory(pluginZipPath, DependenciesDir, true); + } + catch (InvalidDataException) + { + File.Delete(pluginZipPath); + DownloadFile(PluginUrlGlobal, pluginZipPath); + ZipFile.ExtractToDirectory(pluginZipPath, DependenciesDir, true); + } File.Delete(pluginZipPath); - DownloadPlugin(pluginZipPath); - ZipFile.ExtractToDirectory(pluginZipPath, DependenciesDir, true); } - File.Delete(pluginZipPath); - var patcher = new Patcher(PluginVersion, DependenciesDir); patcher.MainPlugin(); patcher.LogFilePlugin(); @@ -57,7 +67,7 @@ private bool NeedsUpdate(string dllPath) using var cancelAfterDelay = new CancellationTokenSource(TimeSpan.FromSeconds(3)); var remoteVersionString = HttpClient - .GetStringAsync("https://www.iinact.com/updater/version", + .GetStringAsync(IsChinese ? VersionUrlChinese : VersionUrlGlobal, cancelAfterDelay.Token).Result; var remoteVersion = new Version(remoteVersionString); return remoteVersion > plugin.Version; @@ -68,11 +78,11 @@ private bool NeedsUpdate(string dllPath) } } - private void DownloadPlugin(string path) + private void DownloadFile(string url, string path) { using var cancelAfterDelay = new CancellationTokenSource(TimeSpan.FromSeconds(30)); using var downloadStream = HttpClient - .GetStreamAsync("https://www.iinact.com/updater/download", + .GetStreamAsync(url, cancelAfterDelay.Token).Result; using var zipFileStream = new FileStream(path, FileMode.Create); downloadStream.CopyTo(zipFileStream); diff --git a/IINACT/FfxivActPluginWrapper.cs b/IINACT/FfxivActPluginWrapper.cs index 2a4d153..1636c0f 100644 --- a/IINACT/FfxivActPluginWrapper.cs +++ b/IINACT/FfxivActPluginWrapper.cs @@ -77,7 +77,11 @@ public unsafe FfxivActPluginWrapper( ffxivActPlugin = new FFXIV_ACT_Plugin.FFXIV_ACT_Plugin(); ffxivActPlugin.ConfigureIOC(); - OpcodeManager.Instance.SetRegion(GameRegion.Global); + if (dalamudClientLanguage.ToString() == "ChineseSimplified") { + OpcodeManager.Instance.SetRegion(GameRegion.Chinese); + } else { + OpcodeManager.Instance.SetRegion(GameRegion.Global); + } iocContainer = ffxivActPlugin._iocContainer; iocContainer.Resolve().LoadResources(); @@ -143,7 +147,7 @@ public unsafe FfxivActPluginWrapper( Dalamud.ClientLanguage.English => Language.English, Dalamud.ClientLanguage.German => Language.German, Dalamud.ClientLanguage.French => Language.French, - _ => Language.English + _ => dalamudClientLanguage.ToString() == "ChineseSimplified" ? Language.Chinese : Language.English }; public void Dispose() diff --git a/IINACT/Plugin.cs b/IINACT/Plugin.cs index 5ca34b7..820051b 100644 --- a/IINACT/Plugin.cs +++ b/IINACT/Plugin.cs @@ -71,7 +71,7 @@ public Plugin([RequiredVersion("1.0")] DalamudPluginInterface pluginInterface, var fetchDeps = new FetchDependencies.FetchDependencies(Version, PluginInterface.AssemblyLocation.Directory!.FullName, - HttpClient); + DataManager.Language.ToString() == "ChineseSimplified", HttpClient); fetchDeps.GetFfxivPlugin(); diff --git a/machina b/machina index 52f4d1e..712b147 160000 --- a/machina +++ b/machina @@ -1 +1 @@ -Subproject commit 52f4d1e1349e6d35aa6964859c61de429e6d4df7 +Subproject commit 712b147e1e50f0743603c90fd8cc4bfea42b0e69