feat: 新增隐藏更新进度提示框选项

This commit is contained in:
uye
2026-06-29 14:36:57 +08:00
parent ac9dbff483
commit 84b560d3cd
11 changed files with 116 additions and 10 deletions

View File

@@ -6,7 +6,7 @@
// MAA.Updater.exe <ParentProcessId> <RootDir> <ExtractDir> <BackupDir>
// <PackagePath> <SuccessStatusFile> <FailureStatusFile>
// <RelaunchExecutablePath> <PlanFile>
// [--mutex-name <name>] [--show-console]
// [--mutex-name <name>] [--show-console] [--no-progress-ui]
//
// Plan file format (UTF-8 JSON):
// { "packageType": "full|ota", "removeList": ["rel/path", ...], "moveList": ["rel/path", ...] }
@@ -134,6 +134,8 @@ struct ProgressUiTheme
static std::wstring g_logFile;
static bool g_writeConsoleLog = false;
// 用户可通过 --no-progress-ui 显式关闭更新进度窗口
static bool g_suppressProgressUi = false;
static UpdateProgressUi g_progressUi;
static ProgressUiTheme g_progressUiTheme;
@@ -340,7 +342,8 @@ static bool EnsureProgressWindowClassRegistered()
static bool ShouldShowProgressUi()
{
return !g_writeConsoleLog && GetConsoleWindow() == nullptr;
// 控制台输出和进度窗口是两个独立选项,可同时显示;用户可通过 --no-progress-ui 显式关闭进度窗口
return !g_suppressProgressUi;
}
static void PumpProgressUiMessages()
@@ -1800,6 +1803,7 @@ int wmain(int argc, wchar_t* argv[])
std::wstring relaunchExecutable = argv[8];
std::wstring planFile = argv[9];
g_writeConsoleLog = HasArgument(argc, argv, L"--show-console");
g_suppressProgressUi = HasArgument(argc, argv, L"--no-progress-ui");
std::wstring mutexName;
for (int i = 1; i < argc - 1; ++i) {

View File

@@ -44,6 +44,8 @@ public class VersionUpdate : INotifyPropertyChanged
public bool ShowUpdaterConsole { get; set; } = false;
public bool ShowUpdaterProgress { get; set; } = true;
public void OnPropertyChanged(string propertyName, object before, object after)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventDetailArgs(propertyName, before, after));

View File

@@ -248,6 +248,7 @@ public static class ConfigurationKeys
public const string AutoDownloadUpdatePackage = "VersionUpdate.AutoDownloadUpdatePackage";
public const string AutoInstallUpdatePackage = "VersionUpdate.AutoInstallUpdatePackage";
public const string ShowUpdaterConsole = "VersionUpdate.ShowUpdaterConsole";
public const string ShowUpdaterProgress = "VersionUpdate.ShowUpdaterProgress";
public const string PenguinId = "Penguin.Id";
public const string IsDrGrandet = "Penguin.IsDrGrandet"; // 已迁移

View File

@@ -349,7 +349,17 @@ To customize rotation schedules, please use 「{key=InfrastModeCustom}」.</syst
<system:String x:Key="UpdateAutoCheckTip">In-game 00:00 / 18:00 (Server local time 04:00 / 22:00)</system:String>
<system:String x:Key="UpdateAutoDownload">Auto Download Update</system:String>
<system:String x:Key="AutoInstallUpdatePackage">Auto Install Update</system:String>
<system:String x:Key="ShowUpdaterConsole">Show MAA.Updater console output during update</system:String>
<system:String x:Key="ShowUpdaterConsole">Show updater console output during update</system:String>
<system:String x:Key="ShowUpdaterProgress">Show updater progress window</system:String>
<system:String x:Key="ShowUpdaterProgressTip" xml:space="preserve">Shows a standalone progress window from the updater during the update, displaying the current status and file processing progress.
When disabled, you won't be able to see the update progress visually. Do not launch MAA again while an update is in progress, as this may interrupt the update or corrupt files.</system:String>
<system:String x:Key="ShowUpdaterProgressWarning" xml:space="preserve">After disabling the update progress window, no progress will be shown during updates.
Please note:
1. Do not launch MAA again while an update is in progress, otherwise file locks may cause the update to fail or files to become corrupted.
2. If both the progress window and console output are disabled, the update will run with no UI feedback at all, making it hard to tell if it is stuck or has failed.
Are you sure you want to disable the update progress window?</system:String>
<system:String x:Key="UpdateCheckStable">Stable Release</system:String>
<system:String x:Key="UpdateCheckBeta">Beta Release</system:String>
<system:String x:Key="UpdateCheckNightly">Nightly Release</system:String>

View File

@@ -349,7 +349,17 @@
<system:String x:Key="UpdateAutoCheckTip">ゲーム内 00:00 / 18:00サーバー現地時間 04:00 / 22:00</system:String>
<system:String x:Key="UpdateAutoDownload">自動アップデート</system:String>
<system:String x:Key="AutoInstallUpdatePackage">自動インストール更新</system:String>
<system:String x:Key="ShowUpdaterConsole">更新中に MAA.Updater のコンソール出力を表示</system:String>
<system:String x:Key="ShowUpdaterConsole">更新中にアップデーターのコンソール出力を表示</system:String>
<system:String x:Key="ShowUpdaterProgress">アップデーターの進行状況ウィンドウを表示</system:String>
<system:String x:Key="ShowUpdaterProgressTip" xml:space="preserve">更新時にアップデーターが独立した進行状況ウィンドウを表示し、現在のステータスとファイル処理の進捗を示します。
オフにすると更新の進行状況が視覚的に分からなくなります。更新中は MAA を再度起動しないでください。更新が中断されたり、ファイルが破損する可能性があります。</system:String>
<system:String x:Key="ShowUpdaterProgressWarning" xml:space="preserve">更新進行状況ウィンドウをオフにすると、更新中に進行状況が表示されなくなります。
ご注意ください:
1. 更新中は MAA を再度起動しないでください。ファイルの占有により更新が失敗したり、ファイルが破損する可能性があります。
2. 進行状況ウィンドウとコンソール出力の両方をオフにすると、更新中に UI のフィードバックが一切なくなり、停止や失敗の判断が困難になります。
更新進行状況ウィンドウをオフにしてもよろしいですか?</system:String>
<system:String x:Key="UpdateCheckStable">安定版</system:String>
<system:String x:Key="UpdateCheckBeta">ベータ版</system:String>
<system:String x:Key="UpdateCheckNightly">内部テスト版</system:String>

View File

@@ -349,7 +349,17 @@
<system:String x:Key="UpdateAutoCheckTip">게임 내 00:00 / 18:00 (서버 현지 시간 04:00 / 22:00)</system:String>
<system:String x:Key="UpdateAutoDownload">업데이트 자동 다운로드</system:String>
<system:String x:Key="AutoInstallUpdatePackage">업데이트 패키지 자동 설치</system:String>
<system:String x:Key="ShowUpdaterConsole">업데이트 중 MAA.Updater 콘솔 출력 표시</system:String>
<system:String x:Key="ShowUpdaterConsole">업데이트 중 업데이터 콘솔 출력 표시</system:String>
<system:String x:Key="ShowUpdaterProgress">업데이터 진행 창 표시</system:String>
<system:String x:Key="ShowUpdaterProgressTip" xml:space="preserve">업데이트 시 업데이터가 별도의 진행 창을 표시하여 현재 상태와 파일 처리 진행률을 보여줍니다.
끄면 업데이트 진행 상황을 직관적으로 확인할 수 없습니다. 업데이트 중에는 MAA를 다시 실행하지 마세요. 업데이트가 중단되거나 파일이 손상될 수 있습니다.</system:String>
<system:String x:Key="ShowUpdaterProgressWarning" xml:space="preserve">업데이트 진행 창을 끄면 업데이트 중에 진행 상황이 표시되지 않습니다.
주의 사항:
1. 업데이트 중에는 MAA를 다시 실행하지 마세요. 파일 점유로 인해 업데이트가 실패하거나 파일이 손상될 수 있습니다.
2. 진행 창과 콘솔 출력을 모두 끄면 업데이트 중에 UI 피드백이 전혀 표시되지 않아 중단 또는 실패 여부를 판단하기 어렵습니다.
업데이트 진행 창을 끄시겠습니까?</system:String>
<system:String x:Key="UpdateCheckStable">안정 버전</system:String>
<system:String x:Key="UpdateCheckBeta">베타 버전</system:String>
<system:String x:Key="UpdateCheckNightly">개발 버전</system:String>

View File

@@ -349,7 +349,17 @@
<system:String x:Key="UpdateAutoCheckTip">游戏内 00:00 / 18:00对应服务器当地时间 04:00 / 22:00</system:String>
<system:String x:Key="UpdateAutoDownload">自动下载更新包</system:String>
<system:String x:Key="AutoInstallUpdatePackage">自动安装更新包</system:String>
<system:String x:Key="ShowUpdaterConsole">显示 MAA.Updater 控制台输出</system:String>
<system:String x:Key="ShowUpdaterConsole">显示更新程序控制台输出</system:String>
<system:String x:Key="ShowUpdaterProgress">显示更新程序进度窗口</system:String>
<system:String x:Key="ShowUpdaterProgressTip" xml:space="preserve">更新时由更新程序显示一个独立的进度窗口,展示当前更新状态与文件处理进度。
关闭后将无法直观看到更新进展,更新过程中也不要重复启动 MAA否则可能导致更新中断或文件损坏。</system:String>
<system:String x:Key="ShowUpdaterProgressWarning" xml:space="preserve">关闭更新进度窗口后,更新过程中将不再显示进度提示。
请注意:
1. 更新期间请勿重复启动 MAA否则可能因文件占用导致更新失败或文件损坏。
2. 若同时关闭了进度窗口和控制台输出,更新过程将完全无界面提示,难以判断是否卡住或失败。
确定要关闭更新进度窗口吗?</system:String>
<system:String x:Key="UpdateCheckStable">正式版</system:String>
<system:String x:Key="UpdateCheckBeta">公测版</system:String>
<system:String x:Key="UpdateCheckNightly">内测版</system:String>

View File

@@ -349,7 +349,17 @@
<system:String x:Key="UpdateAutoCheckTip">遊戲內 00:00 / 18:00對應伺服器當地時間 04:00 / 22:00</system:String>
<system:String x:Key="UpdateAutoDownload">自動下載更新檔</system:String>
<system:String x:Key="AutoInstallUpdatePackage">自動安裝更新檔</system:String>
<system:String x:Key="ShowUpdaterConsole">顯示 MAA.Updater 主控台輸出</system:String>
<system:String x:Key="ShowUpdaterConsole">顯示更新程式主控台輸出</system:String>
<system:String x:Key="ShowUpdaterProgress">顯示更新程式進度視窗</system:String>
<system:String x:Key="ShowUpdaterProgressTip" xml:space="preserve">更新時由更新程式顯示一個獨立的進度視窗,展示目前更新狀態與檔案處理進度。
關閉後將無法直觀看到更新進展,更新過程中也不要重複啟動 MAA否則可能導致更新中斷或檔案損壞。</system:String>
<system:String x:Key="ShowUpdaterProgressWarning" xml:space="preserve">關閉更新進度視窗後,更新過程中將不再顯示進度提示。
請注意:
1. 更新期間請勿重複啟動 MAA否則可能因檔案佔用導致更新失敗或檔案損壞。
2. 若同時關閉了進度視窗和主控台輸出,更新過程將完全無介面提示,難以判斷是否卡住或失敗。
確定要關閉更新進度視窗嗎?</system:String>
<system:String x:Key="UpdateCheckStable">穩定版</system:String>
<system:String x:Key="UpdateCheckBeta">公測版</system:String>
<system:String x:Key="UpdateCheckNightly">內測版</system:String>

View File

@@ -445,6 +445,7 @@ internal static partial class PendingUpdateApplier
IReadOnlyList<string> moveEntries)
{
bool showUpdaterConsole = ConfigurationHelper.GetGlobalValue(ConfigurationKeys.ShowUpdaterConsole, false);
bool showUpdaterProgress = ConfigurationHelper.GetGlobalValue(ConfigurationKeys.ShowUpdaterProgress, true);
string planPath = Path.Combine(context.RootDir, $"maa-pending-update-{Guid.NewGuid():N}.json");
string updaterExecutablePath = PrepareDelegatedUpdaterExecutable(context);
string relaunchExecutablePath = Path.Combine(context.RootDir, "MAA.exe");
@@ -462,7 +463,7 @@ internal static partial class PendingUpdateApplier
// Args: <ParentPid> <RootDir> <ExtractDir> <BackupDir>
// <PackagePath> <SuccessStatusFile> <FailureStatusFile>
// <RelaunchExecutablePath> <PlanFile>
// [--mutex-name <name>] [--show-console]
// [--mutex-name <name>] [--show-console] [--no-progress-ui]
startInfo.ArgumentList.Add(Environment.ProcessId.ToString());
startInfo.ArgumentList.Add(context.RootDir);
startInfo.ArgumentList.Add(context.ExtractDir);
@@ -479,13 +480,19 @@ internal static partial class PendingUpdateApplier
startInfo.ArgumentList.Add("--show-console");
}
if (!showUpdaterProgress)
{
startInfo.ArgumentList.Add("--no-progress-ui");
}
_logger.Information(
"Delegating pending update apply to external updater: packageType={PackageType}, rootDir={RootDir}, extractDir={ExtractDir}, packagePath={PackagePath}, showUpdaterConsole={ShowUpdaterConsole}",
"Delegating pending update apply to external updater: packageType={PackageType}, rootDir={RootDir}, extractDir={ExtractDir}, packagePath={PackagePath}, showUpdaterConsole={ShowUpdaterConsole}, showUpdaterProgress={ShowUpdaterProgress}",
packageType,
context.RootDir,
context.ExtractDir,
context.PackagePath,
showUpdaterConsole);
showUpdaterConsole,
showUpdaterProgress);
if (!File.Exists(updaterExecutablePath))
{

View File

@@ -513,6 +513,36 @@ public class VersionUpdateSettingsUserControlModel : PropertyChangedBase
}
}
private bool _showUpdaterProgress = ConfigurationHelper.GetGlobalValue(ConfigurationKeys.ShowUpdaterProgress, true);
/// <summary>
/// Gets or sets a value indicating whether to show the updater progress window.
/// </summary>
public bool ShowUpdaterProgress
{
get => _showUpdaterProgress;
set {
// 关闭进度窗口属于有风险的操作,需要二次确认
if (!value)
{
var result = MessageBoxHelper.Show(
LocalizationHelper.GetString("ShowUpdaterProgressWarning"),
LocalizationHelper.GetString("Warning"),
MessageBoxButton.YesNo,
MessageBoxImage.Warning,
yes: LocalizationHelper.GetString("Confirm"),
no: LocalizationHelper.GetString("Cancel"));
if (result != MessageBoxResult.Yes)
{
return;
}
}
SetAndNotify(ref _showUpdaterProgress, value);
ConfigurationHelper.SetGlobalValue(ConfigurationKeys.ShowUpdaterProgress, value.ToString());
}
}
/// <summary>
/// Updates manually.
/// </summary>

View File

@@ -79,6 +79,18 @@
IsChecked="{Binding ShowUpdaterConsole}">
<TextBlock Text="{DynamicResource ShowUpdaterConsole}" TextWrapping="Wrap" />
</CheckBox>
<StackPanel
Margin="8"
Orientation="Horizontal">
<CheckBox
MaxWidth="150"
HorizontalAlignment="Left"
VerticalAlignment="Center"
IsChecked="{Binding ShowUpdaterProgress}">
<TextBlock Text="{DynamicResource ShowUpdaterProgress}" TextWrapping="Wrap" />
</CheckBox>
<controls:TooltipBlock TooltipText="{DynamicResource ShowUpdaterProgressTip}" />
</StackPanel>
<StackPanel
Margin="8"
Orientation="Horizontal"