rft: WpfGui游戏设置修改为运行设置 (#11209)

* rft: 暂停下干员

* rft: 掉线自动重连

* rft: 执行脚本

* rft: 不睡眠

* rft: 肉鸽延迟停止

* i18n: 游戏设置->运行设置

* i18n: EN tweak

---------

Co-authored-by: Constrat <56174894+Constrat@users.noreply.github.com>
This commit is contained in:
status102
2024-11-25 20:10:46 +08:00
committed by GitHub
parent 47afd99e66
commit 87514809dc
16 changed files with 385 additions and 359 deletions

View File

@@ -321,7 +321,7 @@ namespace MaaWpfGui.Main
Instances.TaskQueueViewModel.SetInited();
_runningState.SetIdle(true);
AsstSetInstanceOption(InstanceOptionKey.TouchMode, SettingsViewModel.ConnectSettings.TouchMode);
AsstSetInstanceOption(InstanceOptionKey.DeploymentWithPause, SettingsViewModel.ConnectSettings.DeploymentWithPause ? "1" : "0");
AsstSetInstanceOption(InstanceOptionKey.DeploymentWithPause, SettingsViewModel.GameSettings.DeploymentWithPause ? "1" : "0");
AsstSetInstanceOption(InstanceOptionKey.AdbLiteEnabled, SettingsViewModel.ConnectSettings.AdbLiteEnabled ? "1" : "0");
// TODO: 之后把这个 OnUIThread 拆出来
@@ -814,10 +814,10 @@ namespace MaaWpfGui.Main
if (_latestTaskId.ContainsKey(TaskType.Copilot))
{
if (SettingsViewModel.ConnectSettings.CopilotWithScript)
if (SettingsViewModel.GameSettings.CopilotWithScript)
{
Task.Run(() => SettingsViewModel.ConnectSettings.RunScript("EndsWithScript", showLog: false));
if (!string.IsNullOrWhiteSpace(SettingsViewModel.ConnectSettings.EndsWithScript))
Task.Run(() => SettingsViewModel.GameSettings.RunScript("EndsWithScript", showLog: false));
if (!string.IsNullOrWhiteSpace(SettingsViewModel.GameSettings.EndsWithScript))
{
Instances.CopilotViewModel.AddLog(LocalizationHelper.GetString("EndsWithScript"));
}
@@ -1174,7 +1174,7 @@ namespace MaaWpfGui.Main
break;
case "OfflineConfirm":
if (SettingsViewModel.ConnectSettings.AutoRestartOnDrop)
if (SettingsViewModel.GameSettings.AutoRestartOnDrop)
{
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("GameDrop"), UiLogColor.Warning);
}
@@ -1446,7 +1446,7 @@ namespace MaaWpfGui.Main
case "StageInfo":
{
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("StartCombat") + subTaskDetails!["name"]);
if (SettingsViewModel.RoguelikeTask.RoguelikeDelayAbortUntilCombatComplete)
if (SettingsViewModel.GameSettings.RoguelikeDelayAbortUntilCombatComplete)
{
Instances.TaskQueueViewModel.RoguelikeInCombatAndShowWait = true;
}

View File

@@ -4,7 +4,7 @@
<system:String x:Key="GeneralSettings">General</system:String>
<system:String x:Key="AdvancedSettings">Advanced</system:String>
<system:String x:Key="PerformanceSettings">Performance</system:String>
<system:String x:Key="GameSettings">Client</system:String>
<system:String x:Key="GameSettings">Game Settings</system:String>
<system:String x:Key="BaseSettings">Base Setting</system:String>
<system:String x:Key="RoguelikeSettings">I.S.</system:String>
<system:String x:Key="RecruitingSettings">Auto Recruit</system:String>

View File

@@ -4,7 +4,7 @@
<system:String x:Key="GeneralSettings">一般設定</system:String>
<system:String x:Key="AdvancedSettings">高度な設定</system:String>
<system:String x:Key="PerformanceSettings">パフォーマンス設定</system:String>
<system:String x:Key="GameSettings">対象クライアント</system:String>
<system:String x:Key="GameSettings">実行設定</system:String>
<system:String x:Key="BaseSettings">基地設定</system:String>
<system:String x:Key="RoguelikeSettings">統合戦略設定</system:String>
<system:String x:Key="RecruitingSettings">公開求人設定</system:String>
@@ -140,7 +140,7 @@
<system:String x:Key="RoguelikeCollapseListTip">英語のセミコロン「;」で区切る、空白のままにするとデフォルトリストが使用されます。</system:String>
<system:String x:Key="RoguelikeUseSupportUnit">「最初のオペレーター」をサポートから選択</system:String>
<system:String x:Key="RoguelikeUseNonFriendSupport">戦友以外のサポートの使用を許可</system:String>
<system:String x:Key="RoguelikeDelayAbortUntilCombatComplete">戦闘終了まえに「停止」を遅らせる</system:String>
<system:String x:Key="RoguelikeDelayAbortUntilCombatComplete">自動ローグ 戦闘終了まえに「停止」を遅らせる</system:String>
<system:String x:Key="RoguelikeStopAtFinalBoss">第5階層のボスの手前で一時停止する</system:String>
<system:String x:Key="DeploymentWithPause">統合戦略/保全駐在でポーズトリックを使用します(ベータ機能のため非推奨です)</system:String>
<system:String x:Key="AdbLiteEnabled">軽量ADBを使用(実験機能)</system:String>

View File

@@ -4,7 +4,7 @@
<system:String x:Key="GeneralSettings">일반 설정</system:String>
<system:String x:Key="AdvancedSettings">고급 설정</system:String>
<system:String x:Key="PerformanceSettings">성능 설정</system:String>
<system:String x:Key="GameSettings">클라이언트</system:String>
<system:String x:Key="GameSettings">실행 설정</system:String>
<system:String x:Key="BaseSettings">기반시설</system:String>
<system:String x:Key="RoguelikeSettings">통합 전략</system:String>
<system:String x:Key="RecruitingSettings">공개모집</system:String>
@@ -140,7 +140,7 @@
<system:String x:Key="RoguelikeCollapseListTip">영어 세미콜론 「;」으로 구분, 비워 두면 기본 목록이 사용됩니다.</system:String>
<system:String x:Key="RoguelikeUseSupportUnit">시작 오퍼레이터로 지원 유닛 사용</system:String>
<system:String x:Key="RoguelikeUseNonFriendSupport">친구가 아니어도 지원 유닛 사용</system:String>
<system:String x:Key="RoguelikeDelayAbortUntilCombatComplete">중지 시 전투 클리어 후 작업 종료</system:String>
<system:String x:Key="RoguelikeDelayAbortUntilCombatComplete">통합전략 중지 시 전투 클리어 후 작업 종료</system:String>
<system:String x:Key="RoguelikeStopAtFinalBoss">5스테이지 보스 앞에서 일시정지</system:String>
<system:String x:Key="DeploymentWithPause" xml:space="preserve">일시정지 상태로 배치하기 - 통합전략, 자동 작전, 보안 파견에 적용 (비권장)</system:String>
<system:String x:Key="AdbLiteEnabled">ADB Lite 사용 (실험적)</system:String>

View File

@@ -4,7 +4,7 @@
<system:String x:Key="GeneralSettings">常规设置</system:String>
<system:String x:Key="AdvancedSettings">高级设置</system:String>
<system:String x:Key="PerformanceSettings">性能设置</system:String>
<system:String x:Key="GameSettings">游戏设置</system:String>
<system:String x:Key="GameSettings">运行设置</system:String>
<system:String x:Key="BaseSettings">基建设置</system:String>
<system:String x:Key="RoguelikeSettings">肉鸽设置</system:String>
<system:String x:Key="RecruitingSettings">自动公招</system:String>
@@ -140,7 +140,7 @@
<system:String x:Key="RoguelikeCollapseListTip">用英文分号「;」隔开,留空将使用默认列表。</system:String>
<system:String x:Key="RoguelikeUseSupportUnit">「开局干员」使用助战</system:String>
<system:String x:Key="RoguelikeUseNonFriendSupport">可以使用非好友助战</system:String>
<system:String x:Key="RoguelikeDelayAbortUntilCombatComplete">在战斗结束前延迟「停止」动作</system:String>
<system:String x:Key="RoguelikeDelayAbortUntilCombatComplete">自动肉鸽在战斗结束前延迟「停止」动作</system:String>
<system:String x:Key="RoguelikeStopAtFinalBoss">在第五层 BOSS 前暂停</system:String>
<system:String x:Key="DeploymentWithPause">划火柴模式(自动战斗)</system:String>
<system:String x:Key="AdbLiteEnabled">使用 ADB Lite实验性功能</system:String>

View File

@@ -4,7 +4,7 @@
<system:String x:Key="GeneralSettings">常規設定</system:String>
<system:String x:Key="AdvancedSettings">高級設定</system:String>
<system:String x:Key="PerformanceSettings">性能設定</system:String>
<system:String x:Key="GameSettings">遊戲設定</system:String>
<system:String x:Key="GameSettings">運行設定</system:String>
<system:String x:Key="BaseSettings">基建設定</system:String>
<system:String x:Key="RoguelikeSettings">肉鴿設定</system:String>
<system:String x:Key="RecruitingSettings">自動公招</system:String>
@@ -140,7 +140,7 @@
<system:String x:Key="RoguelikeCollapseListTip">用英文分号「;」隔开,留空将使用默认列表。</system:String>
<system:String x:Key="RoguelikeUseSupportUnit">「開局幹員」使用助戰</system:String>
<system:String x:Key="RoguelikeUseNonFriendSupport">可以使用非好友助戰</system:String>
<system:String x:Key="RoguelikeDelayAbortUntilCombatComplete">在戰鬥結束前延遲「停止」動作</system:String>
<system:String x:Key="RoguelikeDelayAbortUntilCombatComplete">肉鴿在戰鬥結束前延遲「停止」動作</system:String>
<system:String x:Key="RoguelikeStopAtFinalBoss">在第五層 BOSS 前暫停</system:String>
<system:String x:Key="DeploymentWithPause">暫停下幹員(同時影響肉鴿、自動戰鬥、保全)(不穩定,暫不推薦開啟)</system:String>
<system:String x:Key="AdbLiteEnabled">使用 ADB Lite實驗性功能</system:String>

View File

@@ -1024,10 +1024,10 @@ namespace MaaWpfGui.ViewModels.UI
return;
}
if (SettingsViewModel.ConnectSettings.CopilotWithScript)
if (SettingsViewModel.GameSettings.CopilotWithScript)
{
await Task.Run(() => SettingsViewModel.ConnectSettings.RunScript("StartsWithScript", showLog: false));
if (!string.IsNullOrWhiteSpace(SettingsViewModel.ConnectSettings.StartsWithScript))
await Task.Run(() => SettingsViewModel.GameSettings.RunScript("StartsWithScript", showLog: false));
if (!string.IsNullOrWhiteSpace(SettingsViewModel.GameSettings.StartsWithScript))
{
AddLog(LocalizationHelper.GetString("StartsWithScript"));
}
@@ -1112,10 +1112,10 @@ namespace MaaWpfGui.ViewModels.UI
// ReSharper disable once UnusedMember.Global
public void Stop()
{
if (SettingsViewModel.ConnectSettings.CopilotWithScript && SettingsViewModel.ConnectSettings.ManualStopWithScript)
if (SettingsViewModel.GameSettings.CopilotWithScript && SettingsViewModel.GameSettings.ManualStopWithScript)
{
Task.Run(() => SettingsViewModel.ConnectSettings.RunScript("EndsWithScript", showLog: false));
if (!string.IsNullOrWhiteSpace(SettingsViewModel.ConnectSettings.EndsWithScript))
Task.Run(() => SettingsViewModel.GameSettings.RunScript("EndsWithScript", showLog: false));
if (!string.IsNullOrWhiteSpace(SettingsViewModel.GameSettings.EndsWithScript))
{
Instances.CopilotViewModel.AddLog(LocalizationHelper.GetString("EndsWithScript"));
}

View File

@@ -116,7 +116,7 @@ namespace MaaWpfGui.ViewModels.UI
/// </summary>
public async void CheckAfterCompleted()
{
await Task.Run(() => SettingsViewModel.ConnectSettings.RunScript("EndsWithScript"));
await Task.Run(() => SettingsViewModel.GameSettings.RunScript("EndsWithScript"));
var actions = TaskSettingDataContext.PostActionSetting;
_logger.Information("Post actions: " + actions.ActionDescription);
@@ -1219,7 +1219,7 @@ namespace MaaWpfGui.ViewModels.UI
InfrastTaskRunning = true;
await Task.Run(() => SettingsViewModel.ConnectSettings.RunScript("StartsWithScript"));
await Task.Run(() => SettingsViewModel.GameSettings.RunScript("StartsWithScript"));
AddLog(LocalizationHelper.GetString("ConnectingToEmulator"));
@@ -1373,7 +1373,7 @@ namespace MaaWpfGui.ViewModels.UI
{
Waiting = true;
AddLog(LocalizationHelper.GetString("Waiting"));
if (SettingsViewModel.RoguelikeTask.RoguelikeDelayAbortUntilCombatComplete)
if (SettingsViewModel.GameSettings.RoguelikeDelayAbortUntilCombatComplete)
{
await WaitUntilRoguelikeCombatComplete();
@@ -1390,7 +1390,7 @@ namespace MaaWpfGui.ViewModels.UI
private async Task WaitUntilRoguelikeCombatComplete()
{
int time = 0;
while (SettingsViewModel.RoguelikeTask.RoguelikeDelayAbortUntilCombatComplete && RoguelikeInCombatAndShowWait && time < 600 && !Stopping)
while (SettingsViewModel.GameSettings.RoguelikeDelayAbortUntilCombatComplete && RoguelikeInCombatAndShowWait && time < 600 && !Stopping)
{
await Task.Delay(1000);
++time;
@@ -1408,9 +1408,9 @@ namespace MaaWpfGui.ViewModels.UI
public void SetStopped()
{
SleepManagement.AllowSleep();
if (SettingsViewModel.ConnectSettings.ManualStopWithScript)
if (SettingsViewModel.GameSettings.ManualStopWithScript)
{
Task.Run(() => SettingsViewModel.ConnectSettings.RunScript("EndsWithScript"));
Task.Run(() => SettingsViewModel.GameSettings.RunScript("EndsWithScript"));
}
if (!_runningState.GetIdle() || Stopping)
@@ -1438,7 +1438,7 @@ namespace MaaWpfGui.ViewModels.UI
ClearLog();
await Task.Run(() => SettingsViewModel.ConnectSettings.RunScript("StartsWithScript"));
await Task.Run(() => SettingsViewModel.GameSettings.RunScript("StartsWithScript"));
AddLog(LocalizationHelper.GetString("ConnectingToEmulator"));

View File

@@ -608,19 +608,6 @@ public class ConnectSettingsUserControlModel : PropertyChangedBase
}
}
private bool _deploymentWithPause = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.RoguelikeDeploymentWithPause, bool.FalseString));
public bool DeploymentWithPause
{
get => _deploymentWithPause;
set
{
SetAndNotify(ref _deploymentWithPause, value);
ConfigurationHelper.SetValue(ConfigurationKeys.RoguelikeDeploymentWithPause, value.ToString());
UpdateInstanceSettings();
}
}
private bool _adbLiteEnabled = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.AdbLiteEnabled, bool.FalseString));
public bool AdbLiteEnabled
@@ -912,7 +899,7 @@ public class ConnectSettingsUserControlModel : PropertyChangedBase
public void UpdateInstanceSettings()
{
Instances.AsstProxy.AsstSetInstanceOption(InstanceOptionKey.TouchMode, TouchMode);
Instances.AsstProxy.AsstSetInstanceOption(InstanceOptionKey.DeploymentWithPause, DeploymentWithPause ? "1" : "0");
Instances.AsstProxy.AsstSetInstanceOption(InstanceOptionKey.DeploymentWithPause, SettingsViewModel.GameSettings.DeploymentWithPause ? "1" : "0");
Instances.AsstProxy.AsstSetInstanceOption(InstanceOptionKey.AdbLiteEnabled, AdbLiteEnabled ? "1" : "0");
Instances.AsstProxy.AsstSetInstanceOption(InstanceOptionKey.KillAdbOnExit, KillAdbOnExit ? "1" : "0");
}
@@ -1017,190 +1004,4 @@ public class ConnectSettingsUserControlModel : PropertyChangedBase
}
public bool AdbReplaced { get; set; } = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.AdbReplaced, bool.FalseString));
private bool _autoRestartOnDrop = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.AutoRestartOnDrop, "True"));
public bool AutoRestartOnDrop
{
get => _autoRestartOnDrop;
set
{
SetAndNotify(ref _autoRestartOnDrop, value);
ConfigurationHelper.SetValue(ConfigurationKeys.AutoRestartOnDrop, value.ToString());
}
}
private string _startsWithScript = ConfigurationHelper.GetValue(ConfigurationKeys.StartsWithScript, string.Empty);
public string StartsWithScript
{
get => _startsWithScript;
set
{
SetAndNotify(ref _startsWithScript, value);
ConfigurationHelper.SetValue(ConfigurationKeys.StartsWithScript, value);
}
}
private string _endsWithScript = ConfigurationHelper.GetValue(ConfigurationKeys.EndsWithScript, string.Empty);
public string EndsWithScript
{
get => _endsWithScript;
set
{
SetAndNotify(ref _endsWithScript, value);
ConfigurationHelper.SetValue(ConfigurationKeys.EndsWithScript, value);
}
}
private bool _copilotWithScript = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.CopilotWithScript, bool.FalseString));
public bool CopilotWithScript
{
get => _copilotWithScript;
set
{
SetAndNotify(ref _copilotWithScript, value);
ConfigurationHelper.SetValue(ConfigurationKeys.CopilotWithScript, value.ToString());
}
}
private bool _manualStopWithScript = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.ManualStopWithScript, bool.FalseString));
public bool ManualStopWithScript
{
get => _manualStopWithScript;
set
{
SetAndNotify(ref _manualStopWithScript, value);
ConfigurationHelper.SetValue(ConfigurationKeys.ManualStopWithScript, value.ToString());
}
}
private bool _blockSleep = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.BlockSleep, bool.FalseString));
public bool BlockSleep
{
get => _blockSleep;
set
{
SetAndNotify(ref _blockSleep, value);
SleepManagement.SetBlockSleep(value);
ConfigurationHelper.SetValue(ConfigurationKeys.BlockSleep, value.ToString());
}
}
private bool _blockSleepWithScreenOn = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.BlockSleepWithScreenOn, bool.TrueString));
public bool BlockSleepWithScreenOn
{
get => _blockSleepWithScreenOn;
set
{
SetAndNotify(ref _blockSleepWithScreenOn, value);
SleepManagement.SetBlockSleepWithScreenOn(value);
ConfigurationHelper.SetValue(ConfigurationKeys.BlockSleepWithScreenOn, value.ToString());
}
}
public void RunScript(string str, bool showLog = true)
{
bool enable = str switch
{
"StartsWithScript" => !string.IsNullOrWhiteSpace(StartsWithScript),
"EndsWithScript" => !string.IsNullOrWhiteSpace(EndsWithScript),
_ => false,
};
if (!enable)
{
return;
}
Func<bool> func = str switch
{
"StartsWithScript" => () => ExecuteScript(StartsWithScript),
"EndsWithScript" => () => ExecuteScript(EndsWithScript),
_ => () => false,
};
if (!showLog)
{
if (!func())
{
_logger.Warning("Failed to execute the script.");
}
return;
}
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("StartTask") + LocalizationHelper.GetString(str));
if (func())
{
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("CompleteTask") + LocalizationHelper.GetString(str));
}
else
{
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("TaskError") + LocalizationHelper.GetString(str), UiLogColor.Warning);
}
}
private static bool ExecuteScript(string scriptPath)
{
try
{
if (string.IsNullOrWhiteSpace(scriptPath))
{
return false;
}
string fileName;
string arguments;
if (scriptPath.StartsWith('\"'))
{
var parts = scriptPath.Split("\"", 3);
fileName = parts[1];
arguments = parts.Length > 2 ? parts[2] : string.Empty;
}
else
{
fileName = scriptPath;
arguments = string.Empty;
}
bool createNoWindow = arguments.Contains("-noWindow");
bool minimized = arguments.Contains("-minimized");
if (createNoWindow)
{
arguments = arguments.Replace("-noWindow", string.Empty).Trim();
}
if (minimized)
{
arguments = arguments.Replace("-minimized", string.Empty).Trim();
}
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = fileName,
Arguments = arguments,
WindowStyle = minimized ? ProcessWindowStyle.Minimized : ProcessWindowStyle.Normal,
CreateNoWindow = createNoWindow,
UseShellExecute = !createNoWindow,
},
};
process.Start();
process.WaitForExit();
return true;
}
catch (Exception)
{
return false;
}
}
}

View File

@@ -12,17 +12,23 @@
// </copyright>
#nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics;
using MaaWpfGui.Constants;
using MaaWpfGui.Helper;
using MaaWpfGui.Utilities;
using MaaWpfGui.Utilities.ValueType;
using MaaWpfGui.ViewModels.UI;
using Serilog;
using Stylet;
namespace MaaWpfGui.ViewModels.UserControl.Settings;
public class GameSettingsUserControlModel : PropertyChangedBase
{
private static readonly ILogger _logger = Log.ForContext<GameSettingsUserControlModel>();
private static VersionUpdateSettingsUserControlModel VersionUpdateSettings => SettingsViewModel.VersionUpdateSettings;
/// <summary>
@@ -61,4 +67,218 @@ public class GameSettingsUserControlModel : PropertyChangedBase
SettingsViewModel.AskRestartToApplySettings(_clientType is "YoStarEN");
}
}
private bool _deploymentWithPause = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.RoguelikeDeploymentWithPause, bool.FalseString));
public bool DeploymentWithPause
{
get => _deploymentWithPause;
set
{
SetAndNotify(ref _deploymentWithPause, value);
ConfigurationHelper.SetValue(ConfigurationKeys.RoguelikeDeploymentWithPause, value.ToString());
SettingsViewModel.ConnectSettings.UpdateInstanceSettings();
}
}
private bool _autoRestartOnDrop = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.AutoRestartOnDrop, bool.TrueString));
public bool AutoRestartOnDrop
{
get => _autoRestartOnDrop;
set
{
SetAndNotify(ref _autoRestartOnDrop, value);
ConfigurationHelper.SetValue(ConfigurationKeys.AutoRestartOnDrop, value.ToString());
}
}
private bool _roguelikeDelayAbortUntilCombatComplete = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.RoguelikeDelayAbortUntilCombatComplete, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether delay abort until battle complete
/// </summary>
public bool RoguelikeDelayAbortUntilCombatComplete
{
get => _roguelikeDelayAbortUntilCombatComplete;
set
{
SetAndNotify(ref _roguelikeDelayAbortUntilCombatComplete, value);
ConfigurationHelper.SetValue(ConfigurationKeys.RoguelikeDelayAbortUntilCombatComplete, value.ToString());
}
}
private string _startsWithScript = ConfigurationHelper.GetValue(ConfigurationKeys.StartsWithScript, string.Empty);
public string StartsWithScript
{
get => _startsWithScript;
set
{
SetAndNotify(ref _startsWithScript, value);
ConfigurationHelper.SetValue(ConfigurationKeys.StartsWithScript, value);
}
}
private string _endsWithScript = ConfigurationHelper.GetValue(ConfigurationKeys.EndsWithScript, string.Empty);
public string EndsWithScript
{
get => _endsWithScript;
set
{
SetAndNotify(ref _endsWithScript, value);
ConfigurationHelper.SetValue(ConfigurationKeys.EndsWithScript, value);
}
}
private bool _copilotWithScript = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.CopilotWithScript, bool.FalseString));
public bool CopilotWithScript
{
get => _copilotWithScript;
set
{
SetAndNotify(ref _copilotWithScript, value);
ConfigurationHelper.SetValue(ConfigurationKeys.CopilotWithScript, value.ToString());
}
}
private bool _manualStopWithScript = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.ManualStopWithScript, bool.FalseString));
public bool ManualStopWithScript
{
get => _manualStopWithScript;
set
{
SetAndNotify(ref _manualStopWithScript, value);
ConfigurationHelper.SetValue(ConfigurationKeys.ManualStopWithScript, value.ToString());
}
}
public void RunScript(string str, bool showLog = true)
{
bool enable = str switch
{
"StartsWithScript" => !string.IsNullOrWhiteSpace(StartsWithScript),
"EndsWithScript" => !string.IsNullOrWhiteSpace(EndsWithScript),
_ => false,
};
if (!enable)
{
return;
}
Func<bool> func = str switch
{
"StartsWithScript" => () => ExecuteScript(StartsWithScript),
"EndsWithScript" => () => ExecuteScript(EndsWithScript),
_ => () => false,
};
if (!showLog)
{
if (!func())
{
_logger.Warning("Failed to execute the script.");
}
return;
}
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("StartTask") + LocalizationHelper.GetString(str));
if (func())
{
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("CompleteTask") + LocalizationHelper.GetString(str));
}
else
{
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("TaskError") + LocalizationHelper.GetString(str), UiLogColor.Warning);
}
}
private static bool ExecuteScript(string scriptPath)
{
try
{
if (string.IsNullOrWhiteSpace(scriptPath))
{
return false;
}
string fileName;
string arguments;
if (scriptPath.StartsWith('\"'))
{
var parts = scriptPath.Split("\"", 3);
fileName = parts[1];
arguments = parts.Length > 2 ? parts[2] : string.Empty;
}
else
{
fileName = scriptPath;
arguments = string.Empty;
}
bool createNoWindow = arguments.Contains("-noWindow");
bool minimized = arguments.Contains("-minimized");
if (createNoWindow)
{
arguments = arguments.Replace("-noWindow", string.Empty).Trim();
}
if (minimized)
{
arguments = arguments.Replace("-minimized", string.Empty).Trim();
}
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = fileName,
Arguments = arguments,
WindowStyle = minimized ? ProcessWindowStyle.Minimized : ProcessWindowStyle.Normal,
CreateNoWindow = createNoWindow,
UseShellExecute = !createNoWindow,
},
};
process.Start();
process.WaitForExit();
return true;
}
catch (Exception)
{
return false;
}
}
private bool _blockSleep = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.BlockSleep, bool.FalseString));
public bool BlockSleep
{
get => _blockSleep;
set
{
SetAndNotify(ref _blockSleep, value);
SleepManagement.SetBlockSleep(value);
ConfigurationHelper.SetValue(ConfigurationKeys.BlockSleep, value.ToString());
}
}
private bool _blockSleepWithScreenOn = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.BlockSleepWithScreenOn, bool.TrueString));
public bool BlockSleepWithScreenOn
{
get => _blockSleepWithScreenOn;
set
{
SetAndNotify(ref _blockSleepWithScreenOn, value);
SleepManagement.SetBlockSleepWithScreenOn(value);
ConfigurationHelper.SetValue(ConfigurationKeys.BlockSleepWithScreenOn, value.ToString());
}
}
}

View File

@@ -568,22 +568,7 @@ public class RoguelikeSettingsUserControlModel : PropertyChangedBase
}
}
private bool _roguelikeDelayAbortUntilCombatComplete = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.RoguelikeDelayAbortUntilCombatComplete, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether delay abort until battle complete
/// </summary>
public bool RoguelikeDelayAbortUntilCombatComplete
{
get => _roguelikeDelayAbortUntilCombatComplete;
set
{
SetAndNotify(ref _roguelikeDelayAbortUntilCombatComplete, value);
ConfigurationHelper.SetValue(ConfigurationKeys.RoguelikeDelayAbortUntilCombatComplete, value.ToString());
}
}
private string _roguelikeStartsCount = ConfigurationHelper.GetValue(ConfigurationKeys.RoguelikeStartsCount, "9999999");
private string _roguelikeStartsCount = ConfigurationHelper.GetValue(ConfigurationKeys.RoguelikeStartsCount, "99999");
/// <summary>
/// Gets or sets the start count of roguelike.

View File

@@ -6,8 +6,8 @@
xmlns:controls="clr-namespace:MaaWpfGui.Styles.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="urn:gong-wpf-dragdrop"
xmlns:helper="clr-namespace:MaaWpfGui.Helper"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:helper="clr-namespace:MaaWpfGui.Helper"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:viewModels="clr-namespace:MaaWpfGui.ViewModels.UserControl.Settings"
@@ -26,10 +26,6 @@
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel
Grid.Row="0"
@@ -211,10 +207,6 @@
Margin="20,10"
Content="{DynamicResource AllowAdbHardRestart}"
IsChecked="{Binding AllowAdbHardRestart}" />
<CheckBox
Margin="20,10"
Content="{DynamicResource AutoRestartOption}"
IsChecked="{Binding AutoRestartOnDrop}" />
</StackPanel>
<StackPanel
@@ -254,61 +246,10 @@
Content="{DynamicResource AdbLiteEnabled}"
IsChecked="{Binding AdbLiteEnabled}" />
</StackPanel>
<CheckBox
Margin="20,10"
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsChecked="{Binding DeploymentWithPause}">
<controls:TextBlock
Block.TextAlignment="Center"
Text="{DynamicResource DeploymentWithPause}"
TextWrapping="Wrap" />
</CheckBox>
</StackPanel>
<hc:TextBox
Grid.Row="7"
Width="300"
Height="30"
Margin="10"
hc:InfoElement.Placeholder="Example: &quot;C:\1.cmd&quot; -minimized"
hc:TitleElement.Title="{DynamicResource StartsWithScript}"
hc:TitleElement.TitlePlacement="Left"
AllowDrop="True"
Drop="StartsWithScript_Drop"
PreviewDragOver="TextBox_PreviewDragOver"
Text="{Binding StartsWithScript}" />
<hc:TextBox
Grid.Row="8"
Width="300"
Height="30"
Margin="10"
hc:InfoElement.Placeholder="Example: &quot;C:\1.cmd&quot; -noWindow"
hc:TitleElement.Title="{DynamicResource EndsWithScript}"
hc:TitleElement.TitlePlacement="Left"
AllowDrop="True"
Drop="EndsWithScript_Drop"
PreviewDragOver="TextBox_PreviewDragOver"
Text="{Binding EndsWithScript}" />
<WrapPanel
Grid.Row="9"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<CheckBox
Margin="10"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{DynamicResource CopilotWithScript}"
IsChecked="{Binding CopilotWithScript}" />
<CheckBox
Margin="10"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{DynamicResource ManualStopWithScript}"
IsChecked="{Binding ManualStopWithScript}" />
</WrapPanel>
<StackPanel
Grid.Row="10"
Grid.Row="7"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">

View File

@@ -11,9 +11,6 @@
// but WITHOUT ANY WARRANTY
// </copyright>
using System.Windows;
using MaaWpfGui.ViewModels.UI;
namespace MaaWpfGui.Views.UserControl.Settings
{
/// <summary>
@@ -28,34 +25,5 @@ namespace MaaWpfGui.Views.UserControl.Settings
{
InitializeComponent();
}
private void StartsWithScript_Drop(object sender, DragEventArgs e)
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop))
{
return;
}
// Note that you can have more than one file.
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
SettingsViewModel.ConnectSettings.StartsWithScript = files?[0] ?? string.Empty;
}
private void EndsWithScript_Drop(object sender, DragEventArgs e)
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop))
{
return;
}
// Note that you can have more than one file.
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
SettingsViewModel.ConnectSettings.EndsWithScript = files?[0] ?? string.Empty;
}
private void TextBox_PreviewDragOver(object sender, DragEventArgs e)
{
e.Handled = true;
}
}
}

View File

@@ -7,6 +7,7 @@
xmlns:controls="clr-namespace:MaaWpfGui.Styles.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="urn:gong-wpf-dragdrop"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:helper="clr-namespace:MaaWpfGui.Helper"
xmlns:local="clr-namespace:MaaWpfGui"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -57,5 +58,95 @@
<TextBlock Text="{DynamicResource HelpUsWithOverseasServersTip}" />
</Hyperlink>
</controls:TextBlock>
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<CheckBox
Margin="20,10"
VerticalAlignment="Center"
IsChecked="{Binding DeploymentWithPause}">
<controls:TextBlock
Block.TextAlignment="Center"
Text="{DynamicResource DeploymentWithPause}"
TextWrapping="Wrap" />
</CheckBox>
<CheckBox
Margin="20,10"
Content="{DynamicResource AutoRestartOption}"
IsChecked="{Binding AutoRestartOnDrop}" />
</StackPanel>
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<CheckBox Margin="0,10" IsChecked="{Binding RoguelikeDelayAbortUntilCombatComplete}">
<TextBlock
Block.TextAlignment="Left"
Text="{DynamicResource RoguelikeDelayAbortUntilCombatComplete}"
TextWrapping="Wrap" />
</CheckBox>
</StackPanel>
<hc:TextBox
Grid.Row="7"
Width="300"
Height="30"
Margin="10"
hc:InfoElement.Placeholder="Example: &quot;C:\1.cmd&quot; -minimized"
hc:TitleElement.Title="{DynamicResource StartsWithScript}"
hc:TitleElement.TitlePlacement="Left"
AllowDrop="True"
Drop="StartsWithScript_Drop"
PreviewDragOver="TextBox_PreviewDragOver"
Text="{Binding StartsWithScript}" />
<hc:TextBox
Grid.Row="8"
Width="300"
Height="30"
Margin="10"
hc:InfoElement.Placeholder="Example: &quot;C:\1.cmd&quot; -noWindow"
hc:TitleElement.Title="{DynamicResource EndsWithScript}"
hc:TitleElement.TitlePlacement="Left"
AllowDrop="True"
Drop="EndsWithScript_Drop"
PreviewDragOver="TextBox_PreviewDragOver"
Text="{Binding EndsWithScript}" />
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<CheckBox
Margin="10"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{DynamicResource CopilotWithScript}"
IsChecked="{Binding CopilotWithScript}" />
<CheckBox
Margin="10"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{DynamicResource ManualStopWithScript}"
IsChecked="{Binding ManualStopWithScript}" />
</StackPanel>
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<CheckBox
Margin="10"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{DynamicResource BlockSleep}"
IsChecked="{Binding BlockSleep}" />
<CheckBox
Margin="10"
VerticalAlignment="Center"
Content="{DynamicResource BlockSleepWithScreenOn}"
IsChecked="{Binding BlockSleepWithScreenOn}"
Visibility="{c:Binding BlockSleep}" />
</StackPanel>
</StackPanel>
</UserControl>

View File

@@ -11,6 +11,9 @@
// but WITHOUT ANY WARRANTY
// </copyright>
using System.Windows;
using MaaWpfGui.ViewModels.UI;
namespace MaaWpfGui.Views.UserControl.Settings
{
/// <summary>
@@ -25,5 +28,34 @@ namespace MaaWpfGui.Views.UserControl.Settings
{
InitializeComponent();
}
private void StartsWithScript_Drop(object sender, DragEventArgs e)
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop))
{
return;
}
// Note that you can have more than one file.
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
SettingsViewModel.GameSettings.StartsWithScript = files?[0] ?? string.Empty;
}
private void EndsWithScript_Drop(object sender, DragEventArgs e)
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop))
{
return;
}
// Note that you can have more than one file.
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
SettingsViewModel.GameSettings.EndsWithScript = files?[0] ?? string.Empty;
}
private void TextBox_PreviewDragOver(object sender, DragEventArgs e)
{
e.Handled = true;
}
}
}

View File

@@ -19,15 +19,14 @@
mc:Ignorable="d">
<StackPanel>
<StackPanel IsEnabled="{Binding Idle, Source={x:Static setting:TaskQueueViewModel.TaskSettingDataContext}}" Visibility="{c:Binding !EnableAdvancedSettings, Source={x:Static setting:TaskQueueViewModel.TaskSettingVisibilities}}">
<ComboBox
<hc:ComboBox
Margin="0,5"
hc:InfoElement.Title="{DynamicResource RoguelikeTheme}"
IsHitTestVisible="{Binding Idle, Source={x:Static setting:TaskQueueViewModel.TaskSettingDataContext}}"
ItemsSource="{Binding RoguelikeThemeList}"
SelectedValue="{Binding RoguelikeTheme}"
SelectedValuePath="Value"
Style="{StaticResource ComboBoxExtend}" />
<ComboBox
SelectedValuePath="Value" />
<hc:ComboBox
Margin="0,5"
hc:InfoElement.Title="{DynamicResource RoguelikeDifficulty}"
DisplayMemberPath="Display"
@@ -36,18 +35,16 @@
ScrollViewer.CanContentScroll="False"
SelectedValue="{Binding RoguelikeDifficulty}"
SelectedValuePath="Value"
Style="{StaticResource ComboBoxExtend}"
Visibility="{c:Binding 'RoguelikeTheme != &quot;Phantom&quot;'}" />
<ComboBox
<hc:ComboBox
Margin="0,5"
hc:InfoElement.Title="{DynamicResource Strategy}"
DisplayMemberPath="Display"
IsHitTestVisible="{Binding Path=Idle, Source={x:Static setting:TaskQueueViewModel.TaskSettingDataContext}}"
ItemsSource="{Binding RoguelikeModeList}"
SelectedValue="{Binding RoguelikeMode}"
SelectedValuePath="Value"
Style="{StaticResource ComboBoxExtend}" />
<ComboBox
SelectedValuePath="Value" />
<hc:ComboBox
Margin="0,5"
hc:InfoElement.Title="{DynamicResource StartingSquad}"
DisplayMemberPath="Display"
@@ -55,17 +52,15 @@
ItemsSource="{Binding RoguelikeSquadList}"
MaxDropDownHeight="800"
SelectedValue="{Binding RoguelikeSquad}"
SelectedValuePath="Value"
Style="{StaticResource ComboBoxExtend}" />
<ComboBox
SelectedValuePath="Value" />
<hc:ComboBox
Margin="0,5"
hc:InfoElement.Title="{DynamicResource StartingRoles}"
DisplayMemberPath="Display"
IsHitTestVisible="{Binding Idle, Source={x:Static setting:TaskQueueViewModel.TaskSettingDataContext}}"
ItemsSource="{Binding RoguelikeRolesList}"
SelectedValue="{Binding RoguelikeRoles}"
SelectedValuePath="Value"
Style="{StaticResource ComboBoxExtend}" />
SelectedValuePath="Value" />
<hc:ComboBox
Name="StartingCoreCharComboBox"
Margin="0,5,0,25"
@@ -91,6 +86,7 @@
<hc:NumericUpDown
Margin="0,5"
hc:InfoElement.Title="{DynamicResource StartTimesLimit}"
Maximum="99999"
Minimum="0"
Style="{StaticResource NumericUpDownExtend}"
Value="{Binding RoguelikeStartsCount}" />
@@ -178,7 +174,6 @@
<TextBox
IsReadOnly="{c:Binding !Idle,
Source={x:Static setting:TaskQueueViewModel.TaskSettingDataContext}}"
Style="{StaticResource TextBoxExtend}"
Text="{Binding Roguelike3NewSquad2StartingFoldartals, UpdateSourceTrigger=LostFocus}"
ToolTip="{DynamicResource Roguelike3NewSquad2StartingFoldartalTip}"
Visibility="{c:Binding 'Roguelike3NewSquad2StartingFoldartalRaw and RoguelikeMode == &quot;4&quot; and RoguelikeTheme == &quot;Sami&quot; and RoguelikeSquad == &quot;生活至上分队&quot; '}" />
@@ -186,7 +181,6 @@
hc:InfoElement.Title="{DynamicResource RoguelikeCollapseList}"
IsReadOnly="{c:Binding !Idle,
Source={x:Static setting:TaskQueueViewModel.TaskSettingDataContext}}"
Style="{StaticResource TextBoxExtend}"
Text="{Binding RoguelikeExpectedCollapsalParadigms, UpdateSourceTrigger=LostFocus}"
ToolTip="{DynamicResource RoguelikeCollapseListTip}"
Visibility="{c:Binding 'RoguelikeMode == &quot;5&quot;'}" />
@@ -205,12 +199,6 @@
Text="{DynamicResource RoguelikeUseNonFriendSupport}"
TextWrapping="Wrap" />
</CheckBox>
<CheckBox Margin="0,10" IsChecked="{Binding RoguelikeDelayAbortUntilCombatComplete}">
<TextBlock
Block.TextAlignment="Left"
Text="{DynamicResource RoguelikeDelayAbortUntilCombatComplete}"
TextWrapping="Wrap" />
</CheckBox>
<CheckBox
Margin="0,10"
IsChecked="{Binding RoguelikeStopAtFinalBoss}"