From 6197059f146eb2dce81bca466684b75ed0b41a4e Mon Sep 17 00:00:00 2001 From: Blooym <19539165+Blooym@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:56:39 +0100 Subject: [PATCH] remove FMV fix for UNIX --- .../Compatibility/GameFixes/GameFixApply.cs | 6 +- .../GameFixes/Implementations/MacVideoFix.cs | 81 ------------------- 2 files changed, 1 insertion(+), 86 deletions(-) delete mode 100644 src/XIVLauncher.Common.Unix/Compatibility/GameFixes/Implementations/MacVideoFix.cs diff --git a/src/XIVLauncher.Common.Unix/Compatibility/GameFixes/GameFixApply.cs b/src/XIVLauncher.Common.Unix/Compatibility/GameFixes/GameFixApply.cs index 0216ff72b..4c11d402f 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/GameFixes/GameFixApply.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/GameFixes/GameFixApply.cs @@ -1,5 +1,4 @@ using System.IO; -using XIVLauncher.Common.Unix.Compatibility.GameFixes.Implementations; namespace XIVLauncher.Common.Unix.Compatibility.GameFixes; @@ -13,10 +12,7 @@ public class GameFixApply public GameFixApply(DirectoryInfo gameDirectory, DirectoryInfo configDirectory, DirectoryInfo winePrefixDirectory, DirectoryInfo tempDirectory) { - this.fixes = new GameFix[] - { - new MacVideoFix(gameDirectory, configDirectory, winePrefixDirectory, tempDirectory), - }; + this.fixes = new GameFix[] { }; } public void Run() diff --git a/src/XIVLauncher.Common.Unix/Compatibility/GameFixes/Implementations/MacVideoFix.cs b/src/XIVLauncher.Common.Unix/Compatibility/GameFixes/Implementations/MacVideoFix.cs deleted file mode 100644 index bb85e955b..000000000 --- a/src/XIVLauncher.Common.Unix/Compatibility/GameFixes/Implementations/MacVideoFix.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Net.Http; -using System.Threading.Tasks; -using System.Xml.Linq; -using Serilog; -using XIVLauncher.Common.Util; - -namespace XIVLauncher.Common.Unix.Compatibility.GameFixes.Implementations; - -public class MacVideoFix : GameFix -{ - private static async Task GetLatestMacZipUrl() - { - const string SPARKLE_FEED_URL = "https://mac-dl.ffxiv.com/cw/finalfantasy-mac.xml"; - const string FALLBACK_URL = "https://mac-dl.ffxiv.com/cw/finalfantasyxiv-1.1.4.zip"; - - try - { - using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(10) }; - var sparkleFeed = XDocument.Parse(await client.GetStringAsync(SPARKLE_FEED_URL)); - var latestItem = sparkleFeed.Descendants("item").FirstOrDefault(); - var enclosureElement = latestItem?.Element("enclosure"); - var urlAttribute = enclosureElement?.Attribute("url"); - return urlAttribute!.Value; - } - catch (Exception ex) - { - Log.Error(ex, "Failed to extract Mac Zip URL from Sparkle update feed, using static fallback"); - return FALLBACK_URL; - } - } - - public MacVideoFix(DirectoryInfo gameDirectory, DirectoryInfo configDirectory, DirectoryInfo winePrefixDirectory, DirectoryInfo tempDirectory) - : base(gameDirectory, configDirectory, winePrefixDirectory, tempDirectory) - { - } - - public override string LoadingTitle => "Preparing FMV cutscenes..."; - - public override void Apply() - { - var outputDirectory = new DirectoryInfo(Path.Combine(GameDir.FullName, "game", "movie", "ffxiv")); - var movieFileNames = new [] { "00000.bk2", "00001.bk2", "00002.bk2", "00003.bk2" }; - var movieFiles = movieFileNames.Select(movie => new FileInfo(Path.Combine(outputDirectory.FullName, movie))); - - if (movieFiles.All((movieFile) => movieFile.Exists)) - return; - - var zipFilePath = Path.Combine(TempDir.FullName, $"{Guid.NewGuid()}.zip"); - using var client = new HttpClientDownloadWithProgress(GetLatestMacZipUrl().GetAwaiter().GetResult(), zipFilePath); - client.ProgressChanged += (size, downloaded, percentage) => - { - if (percentage != null && size != null) - { - this.UpdateProgress?.Invoke($"{LoadingTitle} ({ApiHelpers.BytesToString(downloaded)}/{ApiHelpers.BytesToString(size.Value)})", true, (float)(percentage.Value / 100f)); - } - }; - - client.Download().GetAwaiter().GetResult(); - - var zipMovieFileNames = movieFileNames.Select(movie => Path.Combine("game", "movie", "ffxiv", movie)); - - using (var archive = ZipFile.OpenRead(zipFilePath)) - { - foreach (var entry in archive.Entries) - { - if (zipMovieFileNames.Any((fileName) => entry.FullName.EndsWith(fileName, StringComparison.OrdinalIgnoreCase))) - { - var destinationPath = Path.Combine(outputDirectory.FullName, entry.Name); - if (!File.Exists(destinationPath)) - entry.ExtractToFile(destinationPath); - } - } - } - - File.Delete(zipFilePath); - } -}