diff --git a/src/MaaCore/Assistant.cpp b/src/MaaCore/Assistant.cpp index fb7944d41a..7a4169e65d 100644 --- a/src/MaaCore/Assistant.cpp +++ b/src/MaaCore/Assistant.cpp @@ -367,7 +367,7 @@ bool Assistant::stop(bool block) bool asst::Assistant::running() const { - return !m_thread_idle; + return m_running; } void Assistant::working_proc() @@ -378,17 +378,20 @@ void Assistant::working_proc() while (true) { std::unique_lock lock(m_mutex); if (m_thread_exit) { + m_running = false; return; } if (m_thread_idle || m_tasks_list.empty()) { finished_tasks.clear(); m_thread_idle = true; + m_running = false; Log.flush(); m_condvar.wait(lock); continue; } + m_running = true; const auto [id, task_ptr] = m_tasks_list.front(); lock.unlock(); // only one instance of working_proc running, unlock here to allow set_task_param to the running task diff --git a/src/MaaCore/Assistant.h b/src/MaaCore/Assistant.h index eae4db47b6..87ca15ad32 100644 --- a/src/MaaCore/Assistant.h +++ b/src/MaaCore/Assistant.h @@ -157,6 +157,7 @@ namespace asst void* m_callback_arg = nullptr; std::atomic_bool m_thread_idle = true; + std::atomic_bool m_running = false; mutable std::mutex m_mutex; std::condition_variable m_condvar; diff --git a/src/MaaWpfGui/Constants/ConfigurationKeys.cs b/src/MaaWpfGui/Constants/ConfigurationKeys.cs index 049b0ee40d..29afc4e42a 100644 --- a/src/MaaWpfGui/Constants/ConfigurationKeys.cs +++ b/src/MaaWpfGui/Constants/ConfigurationKeys.cs @@ -172,5 +172,7 @@ namespace MaaWpfGui.Constants public const string GachaShowDisclaimerNoMore = "Gacha.ShowDisclaimerNoMore"; public const string GuideStepIndex = "Guide.StepIndex"; + + public const string ForceScheduledStart = "Timer.ForceScheduledStart"; } } diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index 91b4d8635f..fa3dc3ddf2 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -171,6 +171,9 @@ namespace MaaWpfGui.Main [DllImport("MaaCore.dll")] private static extern bool AsstStart(AsstHandle handle); + [DllImport("MaaCore.dll")] + private static extern bool AsstRunning(AsstHandle handle); + [DllImport("MaaCore.dll")] private static extern bool AsstStop(AsstHandle handle); @@ -617,18 +620,8 @@ namespace MaaWpfGui.Main _latestTaskId.Clear(); + Instances.TaskQueueViewModel.ResetFightVariables(); Instances.TaskQueueViewModel.Idle = true; - Instances.TaskQueueViewModel.UseStone = false; - if (Instances.TaskQueueViewModel.UseMedicineWithNull == null) - { - Instances.TaskQueueViewModel.UseMedicine = false; - } - - if (Instances.TaskQueueViewModel.HasTimesLimitedWithNull == null) - { - Instances.TaskQueueViewModel.HasTimesLimited = false; - } - Instances.CopilotViewModel.Idle = true; Instances.RecognizerViewModel.GachaDone = true; @@ -1378,16 +1371,21 @@ namespace MaaWpfGui.Main return id != 0; } + public bool AsstAppendCloseDown() + { + AsstStop(); + AsstTaskId id = AsstAppendTaskWithEncoding("CloseDown"); + _latestTaskId[TaskType.CloseDown] = id; + return id != 0; + } + /// /// CloseDown 任务。 /// /// 是否成功。 public bool AsstStartCloseDown() { - AsstStop(); - AsstTaskId id = AsstAppendTaskWithEncoding("CloseDown"); - _latestTaskId[TaskType.CloseDown] = id; - return id != 0 && AsstStart(); + return AsstAppendCloseDown() && AsstStart(); } /// @@ -1747,6 +1745,15 @@ namespace MaaWpfGui.Main return AsstStart(_handle); } + /// + /// 运行中。 + /// + /// 是否正在运行。 + public bool AsstRunning() + { + return AsstRunning(_handle); + } + /// /// 停止。 /// diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml index f406f52879..8e3afb7a69 100644 --- a/src/MaaWpfGui/Res/Localizations/en-us.xaml +++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml @@ -1,4 +1,7 @@ - + Settings General @@ -80,7 +83,7 @@ Starting Roles Starting Operator (CN name only) Only supports the CN name of a single operator, default if not filled. - Select "Starting Operator" from support unit list + Select 「Starting Operator」 from support unit list Enable non-friend support Deployment with Pause (Pause-Trick) (Works for IS, Copilot and SSS) (Beta function, Not recommended yet) Use ADB Lite (Experimental) @@ -170,6 +173,8 @@ Do you want to upgrade MAA immediately? (restart the process) New version found, but no update package Please manually download the full package to update! + Force scheduled start + Stop current task, restart game and start new tasks Timer Switch Configuration Config @@ -234,7 +239,7 @@ Please do not check it when the stage OF-1 is not unlocked. Variable function button Manual entry of stage 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 Standard and Adverse environment +At the end of the level, enter 「Normal/Hard」 to switch between Standard and Adverse environment Auto detect connection This checkbox will be automatically unchecked after each detect is completed, and can be checked again if you need to re-detect Re-detect every times @@ -345,10 +350,10 @@ At the end of the level, enter "Normal/Hard" to switch between Standard and Adve Toolbox Recruitment - This recruit recognition is independent from the "Farming" tab. Please open the in game recruit tag selection screen before pressing "Begin to Recruit" + This recruit recognition is independent from the 「Farming」 tab. Please open the in game recruit tag selection screen before pressing 「Begin to Recruit」 Auto set time Show Potential - Please use the "Operator" task to get the "Potential" information. + Please use the 「Operator」 task to get the 「Potential」 information. Auto select 3★ Tags Auto select 4★ Tags Auto select 5★ Tags @@ -357,7 +362,7 @@ At the end of the level, enter "Normal/Hard" to switch between Standard and Adve Depot - This function is still in testing. If you encouter any unexpected results, please zip the "debug/depot" folder in the installation path and submit an issue on GitHub + This function is still in testing. If you encouter any unexpected results, please zip the 「debug/depot」 folder in the installation path and submit an issue on GitHub Start to Identify Export to Arkplanner Export to Lolicon @@ -365,7 +370,7 @@ At the end of the level, enter "Normal/Hard" to switch between Standard and Adve Operator - This function is still in testing. If you encouter any unexpected results, please zip the "debug/oper" folder in the installation path and submit an issue on GitHub + This function is still in testing. If you encouter any unexpected results, please zip the 「debug/oper」 folder in the installation path and submit an issue on GitHub Not owned: {0}\n\n{1}\n\nOwned: {2}\n\n{3} Start to Identify Copy to Clipboard @@ -374,7 +379,7 @@ At the end of the level, enter "Normal/Hard" to switch between Standard and Adve Video Start to identify Open Directory - For video recognition, please open the "Copilot" tab and drag the strategy video into it.\n + For video recognition, please open the 「Copilot」 tab and drag the strategy video into it.\n The video aspect ratio needs to be 16:9 without interference factors such as black borders, emulator borders, special shapes and screen corrections. Gacha @@ -415,17 +420,17 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla Thanks for the likes!\nThe comment section is already open on the web page, please feel free to leave your comment! Auto Squad Loop Times - "Favourite" marked operators cannot be recognized at this time + 「Favourite」 marked operators cannot be recognized at this time Start Video Link Tips: \n\n - 1. Please use this function only when the "Mission Start" button is visible in game.\n\n - 2. You need turn off the "Auto Squad" when using a friendly 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 + 1. Please use this function only when the 「Mission Start」 button is visible in game.\n\n + 2. You need turn off the 「Auto Squad」 when using a friendly 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 5. Video recognition is now supported, please drag the strategy video to use.\n The video aspect ratio needs to be 16:9 without interference factors such as black borders, emulator borders special shapes and screen corrections.\n\n @@ -442,7 +447,7 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla MAA has encountered an error Details Solution - Please refer to the documentation: "FAQ - Crashes" to solve. + Please refer to the documentation: 「FAQ - Crashes」 to solve. Please close the emulator and ADB or restart your computer, then open MAA with administrator privileges to proceed. The file is occupied, please restart the computer and try again Create a GitHub issue @@ -462,7 +467,7 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla Emulator disconnected, trying to reconnect Reconnection succeeded. Continuing the task Reconnection failed. The connection is down! - Touch mode is not available, please go to "Settings - Connection Settings" to switch to a different touch mode. + Touch mode is not available, please go to 「Settings - Connection Settings」 to switch to a different touch mode. Screencap failed. If it happens repeatedly, try to restart or change the emulator! Recognition error Task error: @@ -562,7 +567,7 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla If checked when 1★ tags are identified, will skip the recruitment. If not checked when 1★ tags are identified, they will be ignored. - 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 won't drink so much next time... diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml index dfa86b02de..6059a9c72d 100644 --- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml +++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml @@ -1,4 +1,7 @@ - + 設定 一般設定 @@ -80,7 +83,7 @@ 最初の職業 最初のオペレーター(一人だけ、中国名のみを入力可能) 一人のオペレーターの中国名のみをサポートします。入力されていない場合はデフォルトになります。 - "最初のオペレーター"をサポートから選択 + 「最初のオペレーター」をサポートから選択 フレンド以外のサポートの使用を許可 統合戦略/保全駐在でポーズトリックを使用します(ベータ機能のため非推奨です) 軽量ADBを使用(実験機能) @@ -170,6 +173,8 @@ MAAをすぐにアップグレードしますか?(処理を再開) 新バージョンが見つかりましたが、アップデートパッケージがありません アップデートするには、手動でフルパッケージをダウンロードしてください! + 強制的なタイミングで起動 + 現在のタスクを停止して、ゲームを再起動し、新しいタスクを開始します タイマー 構成を切り替える 構成名 @@ -234,7 +239,7 @@ スタート画面に表示する便利ボタン ステージ名を入力する (テスト機能)ステージ名と番号(例: 4-10、AP-5、H10-1-Hardなど) -の両方がサポートされています。レベルの最後に"Normal/Hard"を入力することで、標準から強襲/厄難に難易度を切り替えることができます +の両方がサポートされています。レベルの最後に「Normal/Hard」を入力することで、標準から強襲/厄難に難易度を切り替えることができます 接続自動認識 このチェックボックスは、検出が完了するたびに自動的にチェックが外れますが、再検出が必要な場合は再度チェックを入れることができます 毎回再検出する diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml index a9c239225c..cf9bfa90f5 100644 --- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml +++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml @@ -173,6 +173,8 @@ 지금 바로 MAA를 업그레이드하시겠습니까? (프로세스 재시작) 새로운 버전이 확인되지만 업데이트 패키지가 없음 전체 패키지를 수동으로 다운로드해 업데이트해 주세요! + 강제로 예약된 시작 + 현재 작업을 중지하고 게임을 다시 시작하여 새 작업을 시작합니다 타이머 구성 전환 구성 이름 @@ -237,7 +239,7 @@ OF-1을 해금하지 않았다면 선택하지 말아 주세요. 메인 화면 버튼의 기능 스테이지 코드 수동 입력 대부분의 메인 스테이지와 원래 목록(예: 4-10, AP-5, H10-1-Hard)에 있는 스테이지 이름을 지원합니다. - 레벨 끝에서 "Normal / Hard"를 입력하여 일반 및 터프 난이도 간 전환 + 레벨 끝에서 「Normal / Hard」를 입력하여 일반 및 터프 난이도 간 전환 연결 자동 감지 이 체크박스는 감지가 끝나면 자동으로 체크가 해제됩니다. 다시 감지하려면 다시 체크해주세요 매번 재감지 diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml index 137fee189e..6c1996f40b 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml @@ -83,7 +83,7 @@ 开局职业组 开局干员 (单个) 仅支持单个干员中文名,不填写则默认选择。 - “开局干员”使用助战 + 「开局干员」使用助战 可以使用非好友助战 暂停下干员(同时影响肉鸽、自动战斗、保全)(不稳定,暂不推荐开启) 使用 ADB Lite(实验性功能) @@ -173,6 +173,8 @@ 是否立即更新 MAA?(重启进程) 检测到新版本,但未找到增量包 请手动下载完整包更新! + 强制定时启动 + 停止当前任务,重启游戏并开始新任务 定时 切换配置 配置名称 @@ -351,7 +353,7 @@ 小提示: 和主界面的自动公招是两个独立的功能,请手动打开游戏公招 Tags 界面后使用~ 自动设置时间 显示干员潜能(四星及以上) - 请使用“干员识别”获取干员信息。 + 请使用「干员识别」获取干员信息。 自动选择 3 星 Tags 自动选择 4 星 Tags 自动选择 5 星 Tags @@ -377,7 +379,7 @@ 视频识别 开始识别 打开文件夹 - 请打开“自动战斗”页,将攻略视频文件拖入后开始即可。\n + 请打开「自动战斗」页,将攻略视频文件拖入后开始即可。\n 需要视频分辨率为 16:9,且无黑边、模拟器边框、异形屏矫正等干扰因素。 牛牛抽卡 @@ -418,17 +420,17 @@ 感谢评价!\n网页已经开放评论区,欢迎前往留下你的评论! 自动编队 循环次数 - 自动编队暂时无法识别“特别关注”的干员 + 自动编队暂时无法识别「特别关注」的干员 开始 视频链接 小提示: \n\n - 1. 请在有“开始行动”按钮的界面再使用本功能;\n\n - 2. 使用好友助战可以关闭“自动编队”,手动选择干员后开始;\n\n - 3. 模拟悖论需要关闭“自动编队”,并选好技能后处于“开始模拟”按钮的界面再开始;\n\n + 1. 请在有「开始行动」按钮的界面再使用本功能;\n\n + 2. 使用好友助战可以关闭「自动编队」,手动选择干员后开始;\n\n + 3. 模拟悖论需要关闭「自动编队」,并选好技能后处于「开始模拟」按钮的界面再开始;\n\n 4. 保全派驻 在 resource/copilot 文件夹下内置了多份作业。\n - 请手动编队后在“开始部署”界面开始(可配合“循环次数”使用)\n\n + 请手动编队后在「开始部署」界面开始(可配合「循环次数」使用)\n\n 5. 现已支持视频识别,请将攻略视频文件拖入后开始。\n 需要视频分辨率为 16:9,无黑边、模拟器边框、异形屏矫正等干扰元素\n\n @@ -557,7 +559,7 @@ 3 星设置 1:00 而非 9:00 不影响其他星级 Tags 每次执行时最大招募次数 - 手动确认“支援机械” + 手动确认「支援机械」 自动确认 3 星 自动确认 4 星 自动确认 5 星 diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml index 3eff53646d..18a907cadc 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml @@ -173,6 +173,8 @@ 是否立即更新 MAA?(重啟進程) 檢測到新版本,但未找到增量包 請手動下載完整包更新! + 強制定時啟動 + 停止當前任務,重新啟動遊戲並開始新任務 定時 切換配置 配置名稱 @@ -237,7 +239,7 @@ 主介面可選擇按鈕功能 手動輸入關卡代名 支持大部分主線關卡名與原列表的關卡名(如:4-10、AP-5、H10-1-Hard) -可在關卡結尾輸入 "Normal/Hard" 表示需要切換標準與磨難難度 +可在關卡結尾輸入 「Normal/Hard」 表示需要切換標準與磨難難度 自動檢測連接 每次檢測完成後會自動取消勾選,若需要重新檢測可再次勾選 每次重新檢測 diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index 88cf5db9aa..67ac2d451f 100644 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -1728,6 +1728,21 @@ namespace MaaWpfGui.ViewModels.UI public TimerModel TimerModels { get; set; } = new TimerModel(); + private bool _forceScheduledStart = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.ForceScheduledStart, bool.FalseString)); + + /// + /// Gets or sets a value indicating whether to use DrGrandet mode. + /// + public bool ForceScheduledStart + { + get => _forceScheduledStart; + set + { + SetAndNotify(ref _forceScheduledStart, value); + ConfigurationHelper.SetValue(ConfigurationKeys.ForceScheduledStart, value.ToString()); + } + } + /* 刷理智设置 */ private string _penguinId = ConfigurationHelper.GetValue(ConfigurationKeys.PenguinId, string.Empty); diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs index 8151d7190f..c7a0bd5e73 100644 --- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs @@ -193,13 +193,17 @@ namespace MaaWpfGui.ViewModels.UI private void InitTimer() { - _timer.Interval = TimeSpan.FromSeconds(50); + _timer.Interval = TimeSpan.FromSeconds(59); _timer.Tick += Timer1_Elapsed; _timer.Start(); } - private void Timer1_Elapsed(object sender, EventArgs e) + private async void Timer1_Elapsed(object sender, EventArgs e) { + // 提前记录时间,避免等待超过定时时间 + int intHour = DateTime.Now.Hour; + int intMinute = DateTime.Now.Minute; + if (NeedToUpdateDatePrompt()) { UpdateDatePrompt(); @@ -216,13 +220,6 @@ namespace MaaWpfGui.ViewModels.UI }); } - refreshCustomInfrastPlanIndexByPeriod(); - - if (!Idle) - { - return; - } - if (NeedToCheckForUpdates()) { if (Instances.SettingsViewModel.UpdatAutoCheck) @@ -237,8 +234,13 @@ namespace MaaWpfGui.ViewModels.UI } } - int intMinute = DateTime.Now.Minute; - int intHour = DateTime.Now.Hour; + refreshCustomInfrastPlanIndexByPeriod(); + + if (!Idle && !Instances.SettingsViewModel.ForceScheduledStart) + { + return; + } + var timeToStart = false; for (int i = 0; i < 8; ++i) { @@ -253,6 +255,28 @@ namespace MaaWpfGui.ViewModels.UI if (timeToStart) { + if (Instances.SettingsViewModel.ForceScheduledStart) + { + if (!Idle) + { + await Stop(); + } + + int count = 0; + while (Instances.AsstProxy.AsstRunning() && count <= 600) + { + await Task.Delay(100); + count++; + } + + if (!Instances.AsstProxy.AsstAppendCloseDown()) + { + AddLog(LocalizationHelper.GetString("CloseArknightsFailed"), UiLogColor.Error); + } + + ResetFightVariables(); + } + LinkStart(); } } @@ -831,6 +855,13 @@ namespace MaaWpfGui.ViewModels.UI Stopping = true; AddLog(LocalizationHelper.GetString("Stopping")); await Task.Run(Instances.AsstProxy.AsstStop); + + int count = 0; + while (Instances.AsstProxy.AsstRunning() && count <= 600) + { + await Task.Delay(100); + count++; + } } public void SetStopped() @@ -2260,6 +2291,24 @@ namespace MaaWpfGui.ViewModels.UI } } + /// + /// Reset unsaved battle parameters. + /// + public void ResetFightVariables() + { + UseStone = false; + + if (UseMedicineWithNull == null) + { + UseMedicine = false; + } + + if (HasTimesLimitedWithNull == null) + { + HasTimesLimited = false; + } + } + private bool? _useMedicineWithNull = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseMedicine, bool.FalseString)); /// diff --git a/src/MaaWpfGui/Views/UserControl/TimerSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/TimerSettingsUserControl.xaml index 892a09f12f..3d6270e866 100644 --- a/src/MaaWpfGui/Views/UserControl/TimerSettingsUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/TimerSettingsUserControl.xaml @@ -18,302 +18,316 @@ mc:Ignorable="d"> - - - + - - - - - - - - - - - - - - - - - - - - - - - + VerticalContentAlignment="Center" + Content="{DynamicResource ForceScheduledStart}" + IsChecked="{Binding ForceScheduledStart}" + ToolTip="{DynamicResource ForceScheduledStartTip}" /> + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + +