diff --git a/src/MaaWpfGui/Constants/ConfigurationKeys.cs b/src/MaaWpfGui/Constants/ConfigurationKeys.cs
index a5924dc7ac..0c1b5e3917 100644
--- a/src/MaaWpfGui/Constants/ConfigurationKeys.cs
+++ b/src/MaaWpfGui/Constants/ConfigurationKeys.cs
@@ -55,6 +55,7 @@ namespace MaaWpfGui.Constants
public const string AdbPath = "Connect.AdbPath";
public const string ConnectConfig = "Connect.ConnectConfig";
public const string RetryOnAdbDisconnected = "Connect.RetryOnDisconnected";
+ public const string AllowADBRestart = "Connect.AllowADBRestart";
public const string AdbLiteEnabled = "Connect.AdbLiteEnabled";
public const string KillAdbOnExit = "Connect.KillAdbOnExit";
public const string TouchMode = "Connect.TouchMode";
diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs
index 731b1112ff..dd255c438e 100644
--- a/src/MaaWpfGui/Main/AsstProxy.cs
+++ b/src/MaaWpfGui/Main/AsstProxy.cs
@@ -443,7 +443,7 @@ namespace MaaWpfGui.Main
if (Instances.SettingsViewModel.RetryOnDisconnected)
{
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("TryToStartEmulator"), UiLogColor.Error);
- Instances.TaskQueueViewModel.KillEmulator();
+ Instances.TaskQueueViewModel.KillEmulatorModeSwitcher();
await Task.Delay(3000);
await Instances.TaskQueueViewModel.Stop();
Instances.TaskQueueViewModel.SetStopped();
diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml
index 9b859823a0..ae92dea318 100644
--- a/src/MaaWpfGui/Res/Localizations/en-us.xaml
+++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml
@@ -90,7 +90,7 @@
Starting Roles
Starting Oper (single, CN name only)
Only supports the CN name of a single oper, default if not filled.
- Select "Starting Oper" from support unit list
+ Select "Starting Oper" from support unit list
Enable nonfirend support
Deployment with Pause, Works for IS, Copilot and SSS,\nBeta function, Not recommended yet
Use Adb Lite (Experimental)
@@ -265,7 +265,7 @@
Show Base Plan
Variable function button
Manual entry of level names
- Support most main stage names + stage names from the original list (e.g. 4-10, AP-5, H10-1-Hard, etc.)
At the end of the level, enter "Normal/Hard" to switch between Normal and Tough difficulty
+ Support most main stage names + stage names from the original list (e.g. 4-10, AP-5, H10-1-Hard, etc.)
At the end of the level, enter "Normal/Hard" to switch between Normal and Tough difficulty
Auto detect connection
The checkbox will be automatically unchecked after each detect is completed, and can be checked again if you need to re-detect
@@ -276,6 +276,7 @@
Connection Preset
Auto restart emulator when adb reconnection fails
Try restarting the emulator after 20 failed reconnect attempts, Must be checked when using a background timed task and setting the task to close the emulator when finished
+ Attempt to restart ADB after connection failure
@@ -391,7 +392,7 @@
Tip: This recognition is independent from main tab (Farming); need open up in game recruit tag selection screen then begin ~
Auto setting time
Show Potential
- Please use the "Operator" to get information
+ Please use the "Operator" to get information
Auto select 3 ★ Tags
Auto select 4 ★ Tags
Auto select 5 ★ Tags
@@ -420,7 +421,7 @@
Video
Start to identify
Open Directory
- For video recognition, please open the "Copilot" page and drag the strategy video into it.
+ For video recognition, please open the "Copilot" page and drag the strategy video into it.
The video resolution is required to be 16:9, and there are no interference factors such as black borders, emulator borders, and special-shaped screen corrections.
@@ -465,7 +466,7 @@ The video resolution is required to be 16:9, and there are no interference facto
Thanks for the likes!\nThe comment section is already open on the web page, please feel free to leave your comment!
Auto squad
LoopTimes
- The operator of "special focus" cannot be identified at this time
+ The operator of "special focus" cannot be identified at this time
Start
@@ -474,11 +475,11 @@ The video resolution is required to be 16:9, and there are no interference facto
Tips:\n\n
- 1. Please use this function only when "Start" is visible in game.\n\n
- 2. You need turn off the "Auto squad" if using friend support unit, then start with your support unit selected.\n\n
- 3. For Paradox Simulation, you need to turn off "Auto squad" and select the skill before, then start in game "start" screen.\n\n
+ 1. Please use this function only when "Start" is visible in game.\n\n
+ 2. You need turn off the "Auto squad" if using friend support unit, then start with your support unit selected.\n\n
+ 3. For Paradox Simulation, you need to turn off "Auto squad" and select the skill before, then start in game "start" screen.\n\n
4. For SSS, There are multiple built-in files under the resource/copilot folder.\n
- Please start on the "Start Deployment" screen after manual formation (can be used with "Loop times")\n\n
+ Please start on the "Start Deployment" screen after manual formation (can be used with "Loop times")\n\n
5. Video recognition is now supported, please drag the guide video to use. \n
The video resolution is required to be 16:9, and there are no distracting elements such as black borders, emulator borders, and special-shaped screen corrections.\n\n
@@ -584,6 +585,7 @@ The video resolution is required to be 16:9, and there are no interference facto
Identify results:
Connection Failed
Trying to start the emulator
+ Trying to restart the ADB
Please check your connection settings or try restarting the emulator and ADB, or restart your computer
@@ -620,7 +622,7 @@ The video resolution is required to be 16:9, and there are no interference facto
- Dear doctor, ever heard of the new listings of "isopropyl alcohol" in Ms. Closure's store? let's check it out?
+ Dear doctor, ever heard of the new listings of "isopropyl alcohol" in Ms. Closure's store? let's check it out?
Ugh... Ehem
Ah, doctor. Why do you sway, so much in your movement today?
I must not drink, drink so much next time...
diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
index 03d1bd6572..eafb09f6cc 100644
--- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
+++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
@@ -90,7 +90,7 @@
最初の職業
最初のオペレーター(一人だけ、中国名のみを入力可能)
一人のオペレーターの中国名のみをサポートします。入力されていない場合はデフォルトになります。
- "最初のオペレーター"をサポートから選択
+ "最初のオペレーター"をサポートから選択
フレンド以外のサポートの使用を許可
統合戦略/保全駐在でポーズトリックを使用します(ベータ機能のため非推奨です)
軽量Adbを使用(実験機能)
@@ -259,7 +259,7 @@
基地計画を表示する
スタート画面に表示する便利ボタン
ステージ名を入力する
- (テスト機能)ステージ名と番号(例:4-10、AP-5、H10-1-Hardなど)
の両方がサポートされています。レベルの最後に"Normal/Hard"を入力することで、標準から強襲/厄難に難易度を切り替えることができます。
+ (テスト機能)ステージ名と番号(例:4-10、AP-5、H10-1-Hardなど)
の両方がサポートされています。レベルの最後に"Normal/Hard"を入力することで、標準から強襲/厄難に難易度を切り替えることができます。
接続自動認識
このチェックボックスは、検出が完了するたびに自動的にチェックが外れますが、再検出が必要な場合は再度チェックを入れることができます
@@ -270,6 +270,7 @@
接続構成
adb再接続失敗時にエミュレータを自動で再起動
再接続に20回失敗した後、エミュレータを再起動してみてください,バックグラウンドのタイムドタスクを使用し、終了時にエミュレータを終了させるタスクを設定する場合は、必ずチェックを入れること
+ 接続失敗後にADBの再起動を試みる
@@ -574,6 +575,7 @@
認識結果:
接続失敗
エミュレータを起動しようとしています
+ ADBの再起動を試みています
接続設定を確認するか、エミュレータとADBを再起動するか、コンピューターを再起動してください
diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
index e08e3a3b65..bc10adbe77 100644
--- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
+++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
@@ -259,7 +259,7 @@
기반시설 계획 표시
메인 화면 버튼의 기능
스테이지 코드 수동 입력
- 대부분의 메인 스테이지와 원래 목록(예: 4-10, AP-5, H10-1-Hard)에 있는 스테이지 이름을 지원합니다.
레벨 끝에서 "Normal / Hard"를 입력하여 일반 및 터프 난이도 간 전환
+ 대부분의 메인 스테이지와 원래 목록(예: 4-10, AP-5, H10-1-Hard)에 있는 스테이지 이름을 지원합니다.
레벨 끝에서 "Normal / Hard"를 입력하여 일반 및 터프 난이도 간 전환
연결 자동 감지
이 체크박스는 감지가 끝나면 자동으로 체크가 해제됩니다. 다시 감지하려면 다시 체크해주세요.
@@ -270,6 +270,7 @@
연결 프리셋
adb 재연결이 실패하면 자동으로 에뮬레이터를 다시 시작합니다
재연결을 20회 시도해도 실패하면 에뮬레이터를 다시 시작합니다. 백그라운드 예약을 사용하고 작업이 완료되면 에뮬레이터가 종료되도록 설정하려면 반드시 선택해야 합니다.
+ 연결 실패 후 ADB 재시작 시도
@@ -575,6 +576,7 @@
인식 결과:
연결 실패
에뮬레이터를 시작하는 중입니다
+ ADB 재시작을 시도 중입니다
연결 설정을 확인하거나 에뮬레이터와 ADB를 다시 시작하거나 컴퓨터를 재시작해주세요.
diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
index 24cd47827d..c7c14d9c4b 100644
--- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
+++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
@@ -265,7 +265,7 @@
显示基建计划
主界面可选择按钮功能
手动输入关卡名
- 支持大部分主线关卡名与原列表的关卡名(如4-10、AP-5、H10-1-Hard)
可在关卡结尾输入"Normal/Hard"表示需要切换标准与磨难难度
+ 支持大部分主线关卡名与原列表的关卡名(如4-10、AP-5、H10-1-Hard)
可在关卡结尾输入"Normal/Hard"表示需要切换标准与磨难难度
自动检测连接
每次检测完成后会自动取消勾选,若需要重新检测可再次勾选,若反复连接失败可勾选始终自动检测连接
@@ -276,6 +276,7 @@
连接配置
adb 重连失败时自动重启模拟器
重连失败 20 次后尝试重启模拟器,使用后台定时任务且设置任务完成关闭模拟器时请勾选
+ 连接失败后尝试重启 ADB
@@ -584,6 +585,7 @@
识别结果:
连接失败
正在尝试启动模拟器
+ 正在尝试重启 ADB
请检查连接设置或尝试重启模拟器与 ADB 或重启电脑
diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
index 6984a75a76..a6e3b85a7e 100644
--- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
+++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
@@ -259,7 +259,7 @@
顯示基建計劃
主介面可選擇按鈕功能
手動輸入關卡代名
- 支持大部分主線關卡名與原列表的關卡名(如4-10、AP-5、H10-1-Hard)
可在關卡結尾輸入"Normal/Hard"表示需要切換標準與磨難難度
+ 支持大部分主線關卡名與原列表的關卡名(如4-10、AP-5、H10-1-Hard)
可在關卡結尾輸入"Normal/Hard"表示需要切換標準與磨難難度
自動檢測連接
每次檢測完成後會自動取消勾選,若需要重新檢測可再次勾選
@@ -270,6 +270,7 @@
連接配置
adb 重連失敗時自動重啟模擬器
重連失敗 20 次後嘗試重啟模擬器,使用後台定時任務且設置任務完成關閉模擬器時必須勾選
+ 連接失敗後嘗試重啟 ADB
@@ -577,6 +578,7 @@
辨識結果:
連接失敗
正在嘗試啟動模擬器
+ 正在嘗試重啟 ADB
請檢查連接設置或嘗試重啟模擬器與 ADB 或重啟電腦
diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
index 9c7d219f38..cf5ecb158e 100644
--- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
+++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
@@ -730,6 +730,44 @@ namespace MaaWpfGui.ViewModels.UI
Instances.TaskQueueViewModel.Idle = idle;
}
+ ///
+ /// Restarts the ADB (Android Debug Bridge).
+ ///
+ public void RestartADB()
+ {
+ if (!AllowADBRestart)
+ {
+ return;
+ }
+
+ string adbPath = AdbPath;
+
+ if (string.IsNullOrEmpty(adbPath))
+ {
+ return;
+ }
+
+ ProcessStartInfo processStartInfo = new ProcessStartInfo
+ {
+ FileName = "cmd.exe",
+ RedirectStandardInput = true,
+ RedirectStandardOutput = true,
+ CreateNoWindow = true,
+ UseShellExecute = false,
+ };
+
+ Process process = new Process
+ {
+ StartInfo = processStartInfo,
+ };
+
+ process.Start();
+ process.StandardInput.WriteLine($"{adbPath} kill-server");
+ process.StandardInput.WriteLine($"{adbPath} start-server");
+ process.StandardInput.WriteLine("exit");
+ process.WaitForExit();
+ }
+
///
/// Selects the emulator to execute.
///
@@ -2140,6 +2178,21 @@ namespace MaaWpfGui.ViewModels.UI
}
}
+ private bool _allowADBRestart = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.AllowADBRestart, bool.TrueString));
+
+ ///
+ /// Gets or sets a value indicating whether to retry task after adb disconnected.
+ ///
+ public bool AllowADBRestart
+ {
+ get => _allowADBRestart;
+ set
+ {
+ SetAndNotify(ref _allowADBRestart, value);
+ ConfigurationHelper.SetValue(ConfigurationKeys.AllowADBRestart, value.ToString());
+ }
+ }
+
private bool _deploymentWithPause = bool.Parse(ConfigurationHelper.GetValue(ConfigurationKeys.RoguelikeDeploymentWithPause, false.ToString()));
public bool DeploymentWithPause
diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
index 6eb538cc93..69a17dde1c 100644
--- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
+++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
@@ -693,7 +693,6 @@ namespace MaaWpfGui.ViewModels.UI
if (!connected)
{
- AddLog(errMsg, UiLogColor.Error);
AddLog(LocalizationHelper.GetString("ConnectFailed") + "\n" + LocalizationHelper.GetString("TryToStartEmulator"));
await Task.Run(() => Instances.SettingsViewModel.TryToStartEmulator(true));
@@ -704,13 +703,28 @@ namespace MaaWpfGui.ViewModels.UI
}
connected = await Task.Run(() => Instances.AsstProxy.AsstConnect(ref errMsg));
- if (!connected)
+ }
+
+ if (!connected)
+ {
+ AddLog(LocalizationHelper.GetString("ConnectFailed") + "\n" + LocalizationHelper.GetString("RestartADB"));
+ await Task.Run(() => Instances.SettingsViewModel.RestartADB());
+
+ if (Stopping)
{
- AddLog(errMsg, UiLogColor.Error);
- Idle = true;
SetStopped();
return;
}
+
+ connected = await Task.Run(() => Instances.AsstProxy.AsstConnect(ref errMsg));
+ }
+
+ if (!connected)
+ {
+ AddLog(errMsg, UiLogColor.Error);
+ Idle = true;
+ SetStopped();
+ return;
}
// 一般是点了“停止”按钮了
diff --git a/src/MaaWpfGui/Views/UserControl/ConnectSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/ConnectSettingsUserControl.xaml
index d2d26ae599..219dc7b457 100644
--- a/src/MaaWpfGui/Views/UserControl/ConnectSettingsUserControl.xaml
+++ b/src/MaaWpfGui/Views/UserControl/ConnectSettingsUserControl.xaml
@@ -151,6 +151,10 @@
Content="{DynamicResource RetryOnDisconnected}"
IsChecked="{Binding RetryOnDisconnected}"
ToolTip="{DynamicResource RetryOnDisconnectedTip}" />
+