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..d5bffc6877 100644
--- a/src/MaaWpfGui/Res/Localizations/en-us.xaml
+++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml
@@ -90,11 +90,11 @@
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)
- Kill Adb On Exit
+ Use ADB Lite (Experimental)
+ Kill ADB On Exit
Default
Mind over matter (to be updated)
@@ -222,7 +222,7 @@
Touch Mode
Minitouch (Default)
MaaTouch (Experimental)
- Adb Input (Compatibility)
+ ADB Input (Compatibility)
Addiction Command arguments
Starts with Script
Ends with Script
@@ -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
@@ -274,8 +274,9 @@
Connection address
It will be filled in automatically when you use it for the first time. If you encounter any problems, you can try to manually modify it
Connection Preset
- Auto restart emulator when adb reconnection fails
+ 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
@@ -508,7 +509,7 @@ The video resolution is required to be 16:9, and there are no interference facto
The resource is damaged, please download the full package again
ADB File NOT exists
ADB Download Failed
- Please do it manually (rename adb.exe and replace the adb file in the emulator)
+ Please do it manually (rename adb.exe and replace the ADB file in the emulator)
Successfully Replaced ADB File
Falied to replace ADB file
Temporarily connected using local ADB.
@@ -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..68c7506ae7 100644
--- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
+++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
@@ -90,11 +90,11 @@
最初の職業
最初のオペレーター(一人だけ、中国名のみを入力可能)
一人のオペレーターの中国名のみをサポートします。入力されていない場合はデフォルトになります。
- "最初のオペレーター"をサポートから選択
+ "最初のオペレーター"をサポートから選択
フレンド以外のサポートの使用を許可
統合戦略/保全駐在でポーズトリックを使用します(ベータ機能のため非推奨です)
- 軽量Adbを使用(実験機能)
- 終了時にAdbを終了する
+ 軽量ADBを使用(実験機能)
+ 終了時にADBを終了する
デフォルト
(ミヅキ)心胜于物分队
@@ -216,7 +216,7 @@
タッチモード
Minitouch (標準)
MaaTouch (実験機能)
- Adb Input (互換性)
+ ADB Input (互換性)
追加コマンド
スクリプトを使用して始めます
終了時にスクリプトを使用します
@@ -259,17 +259,18 @@
基地計画を表示する
スタート画面に表示する便利ボタン
ステージ名を入力する
- (テスト機能)ステージ名と番号(例:4-10、AP-5、H10-1-Hardなど)
の両方がサポートされています。レベルの最後に"Normal/Hard"を入力することで、標準から強襲/厄難に難易度を切り替えることができます。
+ (テスト機能)ステージ名と番号(例:4-10、AP-5、H10-1-Hardなど)
の両方がサポートされています。レベルの最後に"Normal/Hard"を入力することで、標準から強襲/厄難に難易度を切り替えることができます。
接続自動認識
このチェックボックスは、検出が完了するたびに自動的にチェックが外れますが、再検出が必要な場合は再度チェックを入れることができます
毎回再検出する
- adbパス(相対/絶対)
+ ADBパス(相対/絶対)
接続先アドレス
問題があれば手動で修正してください。
接続構成
- adb再接続失敗時にエミュレータを自動で再起動
+ ADB再接続失敗時にエミュレータを自動で再起動
再接続に20回失敗した後、エミュレータを再起動してみてください,バックグラウンドのタイムドタスクを使用し、終了時にエミュレータを終了させるタスクを設定する場合は、必ずチェックを入れること
+ 接続失敗後にADBの再起動を試みる
@@ -498,7 +499,7 @@
リソースファイルが破損しています。完全なパッケージを再度ダウンロードしてください
ADBファイルが存在しません
ADBのダウンロードに失敗しました。
- 手動で行ってください(adb.exeの名前を変更し、エミュレーター内のadbファイルを置き換えます)
+ 手動で行ってください(adb.exeの名前を変更し、エミュレーター内のADBファイルを置き換えます)
ADBファイルが正常に置き換えられました。
ADBファイルの置換に失敗しました。
一時的にローカル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..35d7db272e 100644
--- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
+++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
@@ -93,8 +93,8 @@
시작 오퍼레이터로 지원 유닛 사용
친구가 아니어도 지원 유닛 사용
일시정지 상태로 배치하기 - 통합전략, 자동 작전, 보안 파견에 적용\n(베타 기능, 현재 비권장)
- adb Lite 사용 (실험적)
- 종료 시 adb도 종료
+ ADB Lite 사용 (실험적)
+ 종료 시 ADB도 종료
기본값
마음가짐 분대
@@ -133,10 +133,10 @@
전환 가능
실행 파일
- adb 프로그램
+ ADB 프로그램
에뮬레이터를 검색하는 중에 오류가 발생했습니다.\n이 소프트웨어를 관리자로 실행하거나\n수동으로 연결을 설정해 주세요.
- adb를 찾을 수 없었습니다.\n관리자 권한으로 실행하거나\n수동으로 연결 설정해 주세요.
+ ADB를 찾을 수 없었습니다.\n관리자 권한으로 실행하거나\n수동으로 연결 설정해 주세요.
에뮬레이터를 찾을 수 없습니다.\n이 소프트웨어를 관리자로 실행하거나\n수동으로 연결을 설정해 주세요.
여러 에뮬레이터가 실행 중입니다.\n사용하지 않는 에뮬레이터를 종료하거나\n수동으로 연결을 설정해 주세요.
@@ -216,7 +216,7 @@
터치 수행 방식
Minitouch (기본값)
MaaTouch (실험적)
- Adb Input (호환 모드)
+ ADB Input (호환 모드)
추가 변수
시작 시 추가 스크립트
종료 시 추가 스크립트
@@ -259,17 +259,18 @@
기반시설 계획 표시
메인 화면 버튼의 기능
스테이지 코드 수동 입력
- 대부분의 메인 스테이지와 원래 목록(예: 4-10, AP-5, H10-1-Hard)에 있는 스테이지 이름을 지원합니다.
레벨 끝에서 "Normal / Hard"를 입력하여 일반 및 터프 난이도 간 전환
+ 대부분의 메인 스테이지와 원래 목록(예: 4-10, AP-5, H10-1-Hard)에 있는 스테이지 이름을 지원합니다.
레벨 끝에서 "Normal / Hard"를 입력하여 일반 및 터프 난이도 간 전환
연결 자동 감지
이 체크박스는 감지가 끝나면 자동으로 체크가 해제됩니다. 다시 감지하려면 다시 체크해주세요.
매번 재감지
- adb 경로 (상대/절대)
+ ADB 경로 (상대/절대)
연결 주소
문제 발생 시 직접 수정해 주세요
연결 프리셋
- adb 재연결이 실패하면 자동으로 에뮬레이터를 다시 시작합니다
+ ADB 재연결이 실패하면 자동으로 에뮬레이터를 다시 시작합니다
재연결을 20회 시도해도 실패하면 에뮬레이터를 다시 시작합니다. 백그라운드 예약을 사용하고 작업이 완료되면 에뮬레이터가 종료되도록 설정하려면 반드시 선택해야 합니다.
+ 연결 실패 후 ADB 재시작 시도
@@ -490,7 +491,7 @@
세부 정보
해결 방법
FAQ 문서의 크래시 관련 문단을 참고하세요.
- 에뮬레이터와 adb를 종료하거나 컴퓨터를 재시작하고 관리자 권한으로 MAA를 실행해 주세요.
+ 에뮬레이터와 ADB를 종료하거나 컴퓨터를 재시작하고 관리자 권한으로 MAA를 실행해 주세요.
GitHub에 issue 생성
QQ 그룹 가입
오류 메시지 복사
@@ -499,10 +500,10 @@
리소스가 손상되었습니다. 전체 패키지를 다시 다운로드하세요.
ADB 파일이 존재하지 않습니다
ADB 다운로드 실패
- 수동으로 진행해 주세요. (adb.exe의 이름을 바꾸고 에뮬레이터의 adb 파일을 교체해 주세요)
+ 수동으로 진행해 주세요. (adb.exe의 이름을 바꾸고 에뮬레이터의 ADB 파일을 교체해 주세요)
성공적으로 ADB 파일을 교체했습니다
ADB 교체 실패
- 로컬 adb 파일로 임시적으로 연결했습니다.
+ 로컬 ADB 파일로 임시적으로 연결했습니다.
초기화 오류!
에뮬레이터 해상도가 지원되지 않습니다. 16:9 비율로 설정하시고 해상도를 720p 이상으로 설정해주세요.
시뮬레이터 해상도를 가져올 수 없습니다. 시뮬레이터와 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..bddbc3b65a 100644
--- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
+++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
@@ -93,8 +93,8 @@
“开局干员”使用助战
可以使用非好友助战
暂停下干员(同时影响肉鸽、自动战斗、保全)(不稳定,暂不推荐开启)
- 使用 Adb Lite(实验性功能)
- 退出时释放 Adb
+ 使用 ADB Lite(实验性功能)
+ 退出时释放 ADB
默认分队
心胜于物分队
@@ -133,7 +133,7 @@
可切换
可执行文件
- adb程序
+ ADB程序
检测模拟器出错\n请使用管理员权限打开本软件\n或手动设置连接
检测ADB出错\n请使用管理员权限打开本软件\n或手动设置连接
@@ -222,7 +222,7 @@
触控模式
Minitouch(默认)
MaaTouch(实验功能)
- Adb Input(兼容模式)
+ ADB Input(兼容模式)
附加命令
开始前脚本
结束后脚本
@@ -265,17 +265,18 @@
显示基建计划
主界面可选择按钮功能
手动输入关卡名
- 支持大部分主线关卡名与原列表的关卡名(如4-10、AP-5、H10-1-Hard)
可在关卡结尾输入"Normal/Hard"表示需要切换标准与磨难难度
+ 支持大部分主线关卡名与原列表的关卡名(如4-10、AP-5、H10-1-Hard)
可在关卡结尾输入"Normal/Hard"表示需要切换标准与磨难难度
自动检测连接
每次检测完成后会自动取消勾选,若需要重新检测可再次勾选,若反复连接失败可勾选始终自动检测连接
每次重新检测
- adb 路径 (相对/绝对)
+ ADB 路径 (相对/绝对)
连接地址
若遇到问题可尝试手动修改
连接配置
- adb 重连失败时自动重启模拟器
+ ADB 重连失败时自动重启模拟器
重连失败 20 次后尝试重启模拟器,使用后台定时任务且设置任务完成关闭模拟器时请勾选
+ 连接失败后尝试重启 ADB
@@ -508,7 +509,7 @@
资源损坏,请重新下载完整安装包
ADB 路径不存在
ADB 下载失败
- 请手动进行操作(将 adb.exe 重命名后替换上方模拟器自带 adb 即可)
+ 请手动进行操作(将 adb.exe 重命名后替换上方模拟器自带 ADB 即可)
成功替换 ADB 文件
替换 ADB 失败
已临时使用本地 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..c4060ec254 100644
--- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
+++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
@@ -93,8 +93,8 @@
開局幹員使用助戰
可以使用非好友助戰
暫停下幹員(同時影響肉鴿、自動戰鬥、保全)(不穩定,暫不推薦開啟)
- 使用 Adb Lite(實驗性功能)
- 退出時釋放 Adb
+ 使用 ADB Lite(實驗性功能)
+ 退出時釋放 ADB
默認分隊
心勝於物分隊
@@ -133,7 +133,7 @@
可切換
可執行檔
- adb程式
+ ADB程式
檢測模擬器出錯\n請使用管理員許可權打開本軟體\n或手動設定連接
檢測ADB出錯\n請使用管理員權限打開本軟件\n或手動設置連接
@@ -216,7 +216,7 @@
觸控模式
Minitouch(默認)
MaaTouch(實驗功能)
- Adb Input(兼容模式)
+ ADB Input(兼容模式)
附加命令
開始前腳本
結束後腳本
@@ -259,17 +259,18 @@
顯示基建計劃
主介面可選擇按鈕功能
手動輸入關卡代名
- 支持大部分主線關卡名與原列表的關卡名(如4-10、AP-5、H10-1-Hard)
可在關卡結尾輸入"Normal/Hard"表示需要切換標準與磨難難度
+ 支持大部分主線關卡名與原列表的關卡名(如4-10、AP-5、H10-1-Hard)
可在關卡結尾輸入"Normal/Hard"表示需要切換標準與磨難難度
自動檢測連接
每次檢測完成後會自動取消勾選,若需要重新檢測可再次勾選
每次重新檢測
- adb 路徑 (相對/絕對)
+ ADB 路徑 (相對/絕對)
連接地址
若遇到問題可嘗試手動修改
連接配置
- adb 重連失敗時自動重啟模擬器
+ ADB 重連失敗時自動重啟模擬器
重連失敗 20 次後嘗試重啟模擬器,使用後台定時任務且設置任務完成關閉模擬器時必須勾選
+ 連接失敗後嘗試重啟 ADB
@@ -501,7 +502,7 @@
資源損毀,請重新下載完整安裝包
ADB 路徑不存在
ADB 下載失敗
- 請手動進行操作(將 adb.exe 重命名後替換上方模擬器自帶 adb 即可)
+ 請手動進行操作(將 adb.exe 重命名後替換上方模擬器自帶 ADB 即可)
成功替換 ADB 文件
替換 ADB 失敗
已臨時使用本地 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 cfddbc86a2..d1890f53a9 100644
--- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
+++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
@@ -205,7 +205,7 @@ namespace MaaWpfGui.ViewModels.UI
UpdateStageList(false);
// 随机延迟,防止同时更新
- var delayTime = new Random().Next(0, 10 * 60 * 1000);
+ var delayTime = new Random().Next(10, 10 * 60 * 1000);
_ = Task.Run(async () =>
{
await Task.Delay(delayTime);
@@ -367,6 +367,7 @@ namespace MaaWpfGui.ViewModels.UI
var stage1 = Stage1 ??= string.Empty;
var stage2 = Stage2 ??= string.Empty;
var stage3 = Stage3 ??= string.Empty;
+ var rss = RemainingSanityStage ??= string.Empty;
EnableSetFightParams = false;
@@ -381,32 +382,29 @@ namespace MaaWpfGui.ViewModels.UI
AlternateStageList = new ObservableCollection(_stageManager.GetStageList());
+ RemainingSanityStageList = new ObservableCollection(_stageManager.GetStageList())
+ {
+ [0] = new CombinedData { Display = LocalizationHelper.GetString("NoUse"), Value = string.Empty },
+ };
+
// reset closed stages to "Last/Current"
if (!CustomStageCode)
{
Stage1 = StageList.Any(x => x.Value == stage1) ? stage1 : string.Empty;
Stage2 = AlternateStageList.Any(x => x.Value == stage2) ? stage2 : string.Empty;
Stage3 = AlternateStageList.Any(x => x.Value == stage3) ? stage3 : string.Empty;
+ RemainingSanityStage = RemainingSanityStageList.Any(x => x.Value == rss) ? rss : string.Empty;
}
else
{
Stage1 = stage1;
Stage2 = stage2;
Stage3 = stage3;
+ RemainingSanityStage = rss;
}
EnableSetFightParams = true;
}
-
- var rss = RemainingSanityStage ??= string.Empty;
- RemainingSanityStageList = new ObservableCollection(_stageManager.GetStageList())
- {
- [0] = new CombinedData { Display = LocalizationHelper.GetString("NoUse"), Value = string.Empty },
- };
- if (!CustomStageCode)
- {
- RemainingSanityStage = RemainingSanityStageList.Any(x => x.Value == rss) ? rss : string.Empty;
- }
}
private bool NeedToUpdateDatePrompt()
@@ -693,7 +691,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 +701,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;
}
// 一般是点了“停止”按钮了
@@ -1837,7 +1849,7 @@ namespace MaaWpfGui.ViewModels.UI
if (CustomStageCode)
{
// 从后往前删
- if (_stage1.Length != 3)
+ if (_stage1?.Length != 3 && value != null)
{
value = ToUpperAndCheckStage(value);
}
@@ -1867,7 +1879,7 @@ namespace MaaWpfGui.ViewModels.UI
if (CustomStageCode)
{
- if (_stage2.Length != 3)
+ if (_stage2?.Length != 3 && value != null)
{
value = ToUpperAndCheckStage(value);
}
@@ -1897,7 +1909,7 @@ namespace MaaWpfGui.ViewModels.UI
if (CustomStageCode)
{
- if (_stage3.Length != 3)
+ if (_stage3?.Length != 3 && value != null)
{
value = ToUpperAndCheckStage(value);
}
@@ -1961,7 +1973,7 @@ namespace MaaWpfGui.ViewModels.UI
if (CustomStageCode)
{
- if (_remainingSanityStage.Length != 3)
+ if (_remainingSanityStage?.Length != 3 && value != null)
{
value = ToUpperAndCheckStage(value);
}
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}" />
+
dict:
-# try:
-# base_task = zh_json[task["base_task"]]
-# return getBaseTask(base_task)
-# except:
-# return task
+ with open(zh_json_file, 'r', encoding='utf-8') as zh_fh:
+ zh_json: dict = json.load(zh_fh)
-res_keys = []
-for key, value in zh_json.items():
- value: dict
- # check if it has a "text" and if the text is empty
- if value.get("text"):
- # and then check if gl_json has a corresponding one
- try:
- _ = gl_json[key]["text"][0]
- except:
- if any(map(lambda x: re.search(x, key), regex_ignore_list)):
- continue
- # NOTE
- # It is likely that Ascii texts do not need a translation but there is no guarantee.
- # You may want to comment this out in some cases.
- # if getBaseTask(value).get("isAscii", False) is True:
- if all(map(str.isascii, value["text"])):
- continue
+ with open(gl_json_file, 'r', encoding='utf-8') as gl_fh:
+ gl_json: dict = json.load(gl_fh)
- res_keys.append(key + ': ' + ', '.join(value["text"]))
+ # def getBaseTask(task: dict) -> dict:
+ # try:
+ # base_task = zh_json[task["base_task"]]
+ # return getBaseTask(base_task)
+ # except:
+ # return task
- print(key, value["text"])
+ res_keys = []
+ for key, value in zh_json.items():
+ value: dict
+ # check if it has a "text" and if the text is empty
+ if value.get("text"):
+ # and then check if gl_json has a corresponding one
+ try:
+ _ = gl_json[key]["text"][0]
+ except:
+ if any(map(lambda x: re.search(x, key), regex_ignore_list)):
+ continue
+ # NOTE
+ # It is likely that Ascii texts do not need a translation but there is no guarantee.
+ # You may want to comment this out in some cases.
+ # if getBaseTask(value).get("isAscii", False) is True:
+ if all(map(str.isascii, value["text"])):
+ continue
-with open(output_file, 'w', encoding='utf-8') as f:
- f.write('\n'.join(res_keys))
+ res_keys.append(key + ': ' + ', '.join(value["text"]))
+
+ print(key, value["text"])
+
+ with open(output_file, 'w', encoding='utf-8') as f:
+ f.write('\n'.join(res_keys))
+
+ print("Missing translations written to", output_file)
+
+def main():
+ # Get the server name from argument
+ # try:
+ # # server_name = "YoStarJP"
+ # server_names = sys.argv[1:]
+ # for server_name in server_names:
+ # if server_name not in server_list:
+ # raise Exception(f"{server_name} is not a valid server name.")
+ # except Exception as e:
+ # print(e)
+ # server_names = None
+ # while (not server_names):
+ # print("Enter one or more server names separated by space:",
+ # ", ".join(server_list))
+ # t = input()
+ # server_names = t.split() if all(name in server_list for name in t.split()) else None
+
+ server_names = sys.argv[1:]
+ if not server_names:
+ server_names = server_list
+
+ for server_name in server_names:
+ find_missing_translations(server_name)
+
+if __name__ == "__main__":
+ main()
\ No newline at end of file
diff --git a/tools/OverseasClients/FindMissingTemplates.py b/tools/OverseasClients/FindMissingTemplates.py
index e1cf854a67..0ab92897ba 100644
--- a/tools/OverseasClients/FindMissingTemplates.py
+++ b/tools/OverseasClients/FindMissingTemplates.py
@@ -45,54 +45,68 @@ server_list = [
"txwy"
]
-# Get the server name from argument
-try:
- # server_name = YoStarJP
- server_name = sys.argv[1]
- if server_name not in server_list:
- raise
-except Exception:
- server_name = None
- while (not server_name):
- print("Enter one and only one server name:",
- ", ".join(server_list))
- t = input()
- server_name = t if t in server_list else None
-
-
-# Get current directory so script is run at the correct dir
cur_dir = os.path.dirname(os.path.abspath(__file__))
+proj_dir = os.path.join(cur_dir, "../../")
-zh_dir = os.path.join(cur_dir, "../../resource/template/")
-gl_dir = os.path.join(cur_dir, "../../resource/global/",
- server_name, "resource/template/")
+def find_missing_templates(server_name):
-zh_files = [f for f in os.listdir(
- zh_dir) if os.path.isfile(os.path.join(zh_dir, f))]
-gl_files = [f for f in os.listdir(
- gl_dir) if os.path.isfile(os.path.join(gl_dir, f))]
+ zh_dir = os.path.join(proj_dir, "resource/template/")
+ gl_dir = os.path.join(proj_dir, "resource/global/",
+ server_name, "resource/template/")
-with open(os.path.join(cur_dir, ignore_list_file_name)) as f:
- ignore_files = [line.rstrip('\n') for line in f]
+ zh_files = [f for f in os.listdir(
+ zh_dir) if os.path.isfile(os.path.join(zh_dir, f))]
+ gl_files = [f for f in os.listdir(
+ gl_dir) if os.path.isfile(os.path.join(gl_dir, f))]
-# ZH server pics not found in global server nor ignored will be filtered here
-diff_files = [f for f in zh_files if
- not any(map(lambda x: re.search(x, f), regex_ignore_list)) and
- f not in gl_files and
- f not in ignore_files
- ]
+ with open(os.path.join(cur_dir, ignore_list_file_name)) as f:
+ ignore_files = [line.rstrip('\n') for line in f]
-# These pictures will be copied to the missing_templates folder for reference.
-# Contributors of global servers may screenshot the corresponding files.
-# Note this folder is in .gitignore so it will not be uploaded.
-out_dir = os.path.join(cur_dir, "missing_templates/", server_name)
-if os.path.exists(out_dir):
- shutil.rmtree(out_dir)
-os.makedirs(out_dir)
+ # ZH server pics not found in global server nor ignored will be filtered here
+ diff_files = [f for f in zh_files if
+ not any(map(lambda x: re.search(x, f), regex_ignore_list)) and
+ f not in gl_files and
+ f not in ignore_files
+ ]
-for f in diff_files:
- # print(f)
- shutil.copyfile(os.path.join(zh_dir, f), os.path.join(out_dir, f))
+ # These pictures will be copied to the missing_templates folder for reference.
+ # Contributors of global servers may screenshot the corresponding files.
+ # Note this folder is in .gitignore so it will not be uploaded.
+ out_dir = os.path.join(cur_dir, "missing_templates/", server_name)
+ if os.path.exists(out_dir):
+ shutil.rmtree(out_dir)
+ os.makedirs(out_dir)
-print("Pictures not included in", server_name,
- "server resources is copied to missing_templates/" + server_name)
+ for f in diff_files:
+ # print(f)
+ shutil.copyfile(os.path.join(zh_dir, f), os.path.join(out_dir, f))
+
+ print("Pictures not included in", server_name,
+ "server resources is copied to missing_templates/" + server_name)
+
+def main():
+ # Get the server name from argument
+ # try:
+ # # server_name = "YoStarJP"
+ # server_names = sys.argv[1:]
+ # for server_name in server_names:
+ # if server_name not in server_list:
+ # raise Exception(f"{server_name} is not a valid server name.")
+ # except Exception as e:
+ # print(e)
+ # server_names = None
+ # while (not server_names):
+ # print("Enter one or more server names separated by space:",
+ # ", ".join(server_list))
+ # t = input()
+ # server_names = t.split() if all(name in server_list for name in t.split()) else None
+
+ server_names = sys.argv[1:]
+ if not server_names:
+ server_names = server_list
+
+ for server_name in server_names:
+ find_missing_templates(server_name)
+
+if __name__ == "__main__":
+ main()
\ No newline at end of file