SHA256
Localize FFmpeg Download And Driver Warning Dialogs
This commit is contained in:
1 parent
c56175bbc8
commit
abb6f729e4
4 files changed
+69
-23
No files matched your search
+17
-16
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ADOFAIRenderer.Localization;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Net.Http;
|
||||
@@ -128,7 +129,7 @@ internal class FFmpegDownloadUI : MonoBehaviour
|
||||
_window = O5Window.Create(ctx, bgPanelObj.transform, new O5WindowOptions
|
||||
{
|
||||
Id = "RendererMod_FFmpegDownloadDialog",
|
||||
Title = "FFmpeg Library Installation Required",
|
||||
Title = LocalizationManager.Get("ui.ffmpeg_download.title"),
|
||||
Size = new Vector2(580, 270),
|
||||
Draggable = true,
|
||||
Resizable = false,
|
||||
@@ -150,16 +151,16 @@ internal class FFmpegDownloadUI : MonoBehaviour
|
||||
// 3. Description text
|
||||
var descText = O5Factory.ControlText(ctx, content, 18f, noPad: true);
|
||||
var descStrBuilder = new StringBuilder();
|
||||
descStrBuilder.AppendLine("FFmpeg shared libraries are required to render video.");
|
||||
descStrBuilder.AppendLine(LocalizationManager.Get("ui.ffmpeg_download.desc_required"));
|
||||
if (Application.platform == RuntimePlatform.OSXPlayer)
|
||||
{
|
||||
descStrBuilder.AppendLine("For macOS, reliable public builds are unavailable, so FFmpeg 8.1 must be built manually.");
|
||||
descStrBuilder.AppendLine("Click the button below to open the official FFmpeg website.");
|
||||
descStrBuilder.AppendLine(LocalizationManager.Get("ui.ffmpeg_download.desc_mac_build"));
|
||||
descStrBuilder.AppendLine(LocalizationManager.Get("ui.ffmpeg_download.desc_mac_open"));
|
||||
}
|
||||
else
|
||||
{
|
||||
descStrBuilder.AppendLine("Click the button below to automatically download and install from the internet.");
|
||||
descStrBuilder.AppendLine("<color=#aaaaaa><size=13>(Download size: ~70MB, extracted to UserLibs folder)</size></color>");
|
||||
descStrBuilder.AppendLine(LocalizationManager.Get("ui.ffmpeg_download.desc_download"));
|
||||
descStrBuilder.AppendLine(LocalizationManager.Get("ui.ffmpeg_download.desc_size"));
|
||||
}
|
||||
descText.text = descStrBuilder.ToString();
|
||||
descText.alignment = TextAlignmentOptions.Center;
|
||||
@@ -196,7 +197,7 @@ internal class FFmpegDownloadUI : MonoBehaviour
|
||||
ctx: ctx,
|
||||
parent: _buttonContainerObj.transform,
|
||||
onClick: onDownloadClick,
|
||||
text: Application.platform != RuntimePlatform.OSXPlayer ? "Download & Install" : "Open Website",
|
||||
text: LocalizationManager.Get(Application.platform != RuntimePlatform.OSXPlayer ? "ui.ffmpeg_download.btn_download" : "ui.ffmpeg_download.btn_open_site"),
|
||||
id: "btn_ffmpeg_download",
|
||||
height: 40f
|
||||
);
|
||||
@@ -211,7 +212,7 @@ internal class FFmpegDownloadUI : MonoBehaviour
|
||||
ctx: ctx,
|
||||
parent: _buttonContainerObj.transform,
|
||||
onClick: CancelProcess,
|
||||
text: "Cancel",
|
||||
text: LocalizationManager.Get("ui.ffmpeg_download.btn_cancel"),
|
||||
id: "btn_ffmpeg_cancel",
|
||||
height: 40f
|
||||
);
|
||||
@@ -341,7 +342,7 @@ internal class FFmpegDownloadUI : MonoBehaviour
|
||||
string tempZipPath = "";
|
||||
try
|
||||
{
|
||||
UpdateStatus("Starting download...", new Color(0.8f, 0.8f, 0.8f));
|
||||
UpdateStatus(LocalizationManager.Get("ui.ffmpeg_download.status_starting"), new Color(0.8f, 0.8f, 0.8f));
|
||||
UpdateProgress(0f, "0%");
|
||||
|
||||
var userLibsDir = MelonEnvironment.UserLibsDirectory;
|
||||
@@ -361,19 +362,19 @@ internal class FFmpegDownloadUI : MonoBehaviour
|
||||
var progressReporter = new Progress<float>(percent =>
|
||||
{
|
||||
UpdateProgress(percent, $"{percent * 100f:F1}%");
|
||||
UpdateStatus($"Downloading... ({(percent * 100f):F1}%)", new Color(0f, 0.8f, 1f));
|
||||
UpdateStatus(LocalizationManager.Get("ui.ffmpeg_download.status_downloading", $"{percent * 100f:F1}"), new Color(0f, 0.8f, 1f));
|
||||
});
|
||||
|
||||
await DownloadFileAsync(DownloadUrl, tempZipPath, progressReporter, _cts.Token);
|
||||
|
||||
// Extract after download complete
|
||||
UpdateStatus("Extracting and copying library files...", new Color(0.9f, 0.9f, 0.2f));
|
||||
UpdateProgress(0.99f, "Extracting...");
|
||||
UpdateStatus(LocalizationManager.Get("ui.ffmpeg_download.status_extracting"), new Color(0.9f, 0.9f, 0.2f));
|
||||
UpdateProgress(0.99f, LocalizationManager.Get("ui.ffmpeg_download.progress_extracting"));
|
||||
|
||||
await ExtractDllsAsync(tempZipPath, userLibsDir);
|
||||
|
||||
// Update completion status
|
||||
UpdateStatus("FFmpeg installation complete!", new Color(0.2f, 0.9f, 0.2f));
|
||||
UpdateStatus(LocalizationManager.Get("ui.ffmpeg_download.status_complete"), new Color(0.2f, 0.9f, 0.2f));
|
||||
UpdateProgress(1f, "100%");
|
||||
|
||||
await Task.Delay(1000);
|
||||
@@ -395,12 +396,12 @@ internal class FFmpegDownloadUI : MonoBehaviour
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
UpdateStatus("Download was cancelled.", new Color(0.9f, 0.5f, 0.2f));
|
||||
UpdateStatus(LocalizationManager.Get("ui.ffmpeg_download.status_cancelled"), new Color(0.9f, 0.5f, 0.2f));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Melon<RenderMod>.Logger.Error($"Error during FFmpeg download/installation: {ex}");
|
||||
UpdateStatus($"Installation failed: {ex.Message}", new Color(1f, 0.3f, 0.3f));
|
||||
UpdateStatus(LocalizationManager.Get("ui.ffmpeg_download.status_failed", ex.Message), new Color(1f, 0.3f, 0.3f));
|
||||
|
||||
// Reset buttons on failure
|
||||
ExecuteOnMainThread(() =>
|
||||
@@ -410,7 +411,7 @@ internal class FFmpegDownloadUI : MonoBehaviour
|
||||
var downloadBtnText = _buttonContainerObj.transform.Find("DownloadButton/DownloadText")?.GetComponent<TextMeshProUGUI>();
|
||||
if (downloadBtnText)
|
||||
{
|
||||
downloadBtnText.text = "Retry";
|
||||
downloadBtnText.text = LocalizationManager.Get("ui.ffmpeg_download.btn_retry");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user