fix: 自动战斗-战斗列表的突袭关描述从Adverse修正为Raid (#8082)

* fix: 修复WpfGui中对突袭关的错误描述
This commit is contained in:
status102
2024-02-17 19:28:31 +08:00
committed by GitHub
parent 96dc30821d
commit caa6cab82f
8 changed files with 79 additions and 42 deletions

View File

@@ -519,6 +519,7 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla
<system:String x:Key="AddUserAdditionalTip">Use「;」as the separator,「,」to separate the operator name and skills, for example: W, 3; Ash, 2</system:String>
<system:String x:Key="UseCopilotList">Battle list</system:String>
<system:String x:Key="UseCopilotListTip">Please switch to the level selection page before starting</system:String>
<system:String x:Key="CopilotTaskRaidStage">(Raid)</system:String>
<system:String x:Key="CopilotAddTask">Right click to add raid difficulty</system:String>
<system:String x:Key="CopilotClearTask">Right click to clear inactive tasks</system:String>
<system:String x:Key="LoopTimes">Loop Times</system:String>
@@ -540,7 +541,7 @@ The video aspect ratio needs to be 16:9 without interference factors such as bla
Clear: Left click to clear the list, right click to remove only inactive tasks. \n
Before starting, you need to switch to the level selection interface. Cross-chapter navigation is not supported. \n
The operation will be terminated when encountering insufficient sanity, losing the battle, or failing to settle with three stars. \n
When you want to use the batch import to add a adverse level, you need to modify the file name (e.g.: 1-7-Adverse). \n\n
When you want to use the batch import to add a adverse level, you need to modify the file name (e.g.: '1-7(Raid).json'). \n\n
</system:String>
<system:String x:Key="CopilotFileReadError">Failed to read file!</system:String>
<system:String x:Key="CopilotNoFound">No corresponding file found!</system:String>

View File

@@ -519,6 +519,7 @@ Bilibili: ログイン インターフェイスに表示されるアカウント
<system:String x:Key="AddUserAdditionalTip">使用「;」オペレータ名とスキルを区切るには、区切り文字として「,」を使用します。例: W, 3; Ash, 2</system:String>
<system:String x:Key="UseCopilotList">バトルリスト</system:String>
<system:String x:Key="UseCopilotListTip">開始前にレベル選択ページに切り替えてください</system:String>
<system:String x:Key="CopilotTaskRaidStage">(Riad)</system:String>
<system:String x:Key="CopilotAddTask">右クリックしてレイドの難易度を追加します</system:String>
<system:String x:Key="CopilotClearTask">右クリックして非アクティブなタスクをクリアします</system:String>
<system:String x:Key="LoopTimes">ループ回数</system:String>
@@ -540,7 +541,7 @@ Bilibili: ログイン インターフェイスに表示されるアカウント
クリア: 左クリックするとリストがクリアされ、右クリックすると非アクティブなタスクのみが削除されます。\n
開始する前に、レベル選択インターフェースに切り替える必要があります。章間のナビゲーションはサポートされていません。\n
正気度が不十分な場合、戦闘が失敗した場合、または 3 つ星を解決できない場合、アクションは終了します。 \n
一括インポートを使用して逆レベルを追加する場合は、ファイル名を変更する必要があります (例: 1-7-Adverse)。\n\n
一括インポートを使用して逆レベルを追加する場合は、ファイル名を変更する必要があります (例: '1-7(Raid).json')。\n\n
</system:String>
<system:String x:Key="CopilotFileReadError">ファイルの読み取りに失敗しました!</system:String>
<system:String x:Key="CopilotNoFound">対応する攻略ファイルが見つかりません!</system:String>

View File

@@ -519,6 +519,7 @@ Bilibili: 로그인 인터페이스에 표시되는 계정 이름(예: 장산)
<system:String x:Key="AddUserAdditionalTip">사용「;」운영자 이름과 기술을 구분하기 위해 구분 기호「,」를 사용합니다. 예: W, 3; Ash, 2</system:String>
<system:String x:Key="UseCopilotList">전투 목록</system:String>
<system:String x:Key="UseCopilotListTip">시작하기 전에 레벨 선택 페이지로 전환하세요</system:String>
<system:String x:Key="CopilotTaskRaidStage">(Raid)</system:String>
<system:String x:Key="CopilotAddTask">공격대 난이도를 추가하려면 마우스 오른쪽 버튼을 클릭하세요.</system:String>
<system:String x:Key="CopilotClearTask">비활성 작업을 지우려면 마우스 오른쪽 버튼을 클릭하세요.</system:String>
<system:String x:Key="LoopTimes">반복 횟수</system:String>
@@ -540,7 +541,7 @@ Bilibili: 로그인 인터페이스에 표시되는 계정 이름(예: 장산)
지우기: 목록을 지우려면 왼쪽 클릭, 비활성화된 작업만 제거하려면 오른쪽 클릭을 하세요 \n
시작하기 전에 레벨 선택 화면으로 진입해야 합니다. 목표 지점으로의 이동은 지원되지 않습니다. \n
이성이 부족하거나, 전투가 실패하거나, 3성 클리어를 해결할 수 없는 경우 동작이 종료됩니다. \n
일괄 가져오기로 인위적인 레벨을 추가하려면, 파일명을 수정해야합니다(예: 1-7-Adverse).\n\n
일괄 가져오기로 인위적인 레벨을 추가하려면, 파일명을 수정해야합니다(예: '1-7(Raid).json').\n\n
</system:String>
<system:String x:Key="CopilotFileReadError">파일을 읽지 못했습니다!</system:String>
<system:String x:Key="CopilotNoFound">해당 파일을 찾을 수 없습니다!</system:String>

View File

@@ -520,6 +520,7 @@
<system:String x:Key="LoopTimes">循环次数</system:String>
<system:String x:Key="UseCopilotList">战斗列表</system:String>
<system:String x:Key="UseCopilotListTip">开始前请切换至关卡选择页面</system:String>
<system:String x:Key="CopilotTaskRaidStage">(突袭)</system:String>
<system:String x:Key="CopilotAddTask">右键添加突袭难度</system:String>
<system:String x:Key="CopilotClearTask">右键清除未激活任务</system:String>
<system:String x:Key="Start">开始</system:String>
@@ -540,7 +541,7 @@
清除: 左键清空列表,右键仅移除未激活的任务。\n
开始前,需要切换至对应关卡的选择界面,不支持跨章节导航。\n
遇到 理智不足、战斗失败、未能以三星结算 时将会中止运行。\n
批量导入时,添加突袭关需修改文件名 (如: 1-7-Adverse)。\n\n
批量导入时,添加突袭关需修改文件名 (如: '1-7(Raid).json')。\n\n
</system:String>
<system:String x:Key="CopilotFileReadError">读取文件失败!</system:String>
<system:String x:Key="CopilotNoFound">未找到对应作业!</system:String>

View File

@@ -517,6 +517,7 @@
<system:String x:Key="AddUserAdditionalTip">使用「;」作為分隔符,用「,」分隔操作員姓名和技能,例:史尔特尔,3;艾雅法拉,1</system:String>
<system:String x:Key="UseCopilotList">戰鬥列表</system:String>
<system:String x:Key="UseCopilotListTip">開始前請切換至關卡選擇頁面</system:String>
<system:String x:Key="CopilotTaskRaidStage">(突襲)</system:String>
<system:String x:Key="CopilotAddTask">右鍵添加突襲難度</system:String>
<system:String x:Key="CopilotClearTask">右鍵清除未激活任務</system:String>
<system:String x:Key="LoopTimes">循環次數</system:String>
@@ -538,7 +539,7 @@
清除: 左鍵清空列表,右鍵僅移除未激活的任務\n
開始前,需要切換至對應關卡的選擇界面,不支持跨章節導航\n
遇到 理智不足、戰鬥失敗、未能以三星結算 時將會中止運行\n
批次匯入時,新增突襲關需修改檔案名 (如: 1-7-Adverse)\n\n
批次匯入時,新增突襲關需修改檔案名 (如: '1-7(Raid).json')\n\n
</system:String>
<system:String x:Key="CopilotFileReadError">讀取檔案失敗!</system:String>
<system:String x:Key="CopilotNoFound">未找到對應作業!</system:String>

View File

@@ -23,12 +23,14 @@ namespace MaaWpfGui.ViewModels
/// </summary>
/// <param name="name">The name.</param>
/// <param name="filePath">The original Name of file</param>
/// <param name="isRaid">是否为突袭关</param>
/// <param name="copilotId">作业站对应id本地作业应为默认值0</param>
/// <param name="isChecked">isChecked</param>
public CopilotItemViewModel(string name, string filePath, int copilotId = 0, bool isChecked = true)
public CopilotItemViewModel(string name, string filePath, bool isRaid = false, int copilotId = 0, bool isChecked = true)
{
Name = name;
FilePath = filePath;
_isRaid = isRaid;
CopilotId = copilotId;
_isChecked = isChecked;
}
@@ -48,6 +50,21 @@ namespace MaaWpfGui.ViewModels
/// </summary>
public int CopilotId { get; set; }
private bool _isRaid;
/// <summary>
/// Gets or sets a value indicating whether 突袭关
/// </summary>
public bool IsRaid
{
get => _isRaid;
set
{
SetAndNotify(ref _isRaid, value);
Instances.CopilotViewModel.SaveCopilotTask();
}
}
private bool _isChecked;
/// <summary>

View File

@@ -21,7 +21,6 @@ using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using HandyControl.Tools.Extension;
using MaaWpfGui.Constants;
using MaaWpfGui.Helper;
using MaaWpfGui.States;
@@ -74,13 +73,24 @@ namespace MaaWpfGui.ViewModels.UI
}
JArray jArray = JArray.Parse(copilotTaskList);
foreach (var item in jArray)
foreach (var it in jArray)
{
if (((JObject)item).TryGetValue("file_path", out var token) && File.Exists(token.ToString()))
if (it is JObject item && item.TryGetValue("file_path", out var token) && File.Exists(token.ToString()))
{
int copilotIdInFile = ((JObject)item).TryGetValue("copilot_id", out var copilotIdToken) ? (int)copilotIdToken : -1;
int copilotIdInFile = item.TryGetValue("copilot_id", out var copilotIdToken) ? (int)copilotIdToken : -1;
string name = (string)item["name"];
bool isRaid = false;
if (item.ContainsKey("is_raid"))
{
isRaid = (bool)item["is_raid"];
}
else if (name.EndsWith("-Adverse"))
{
name = name.Replace("-Adverse", string.Empty);
isRaid = true; // 用于迁移配置 (since 5.1.0, 后期移除)
}
CopilotItemViewModels.Add(new CopilotItemViewModel((string)item["name"], (string)item["file_path"], copilotIdInFile, (bool)item["is_checked"]));
CopilotItemViewModels.Add(new CopilotItemViewModel(name, (string)item["file_path"], isRaid, copilotIdInFile, (bool)item["is_checked"]));
}
}
@@ -253,7 +263,7 @@ namespace MaaWpfGui.ViewModels.UI
private const string TempCopilotFile = "cache/_temp_copilot.json";
private string _taskType = "General";
private const string StageNameRegex = @"(?:[a-z]{0,3})(?:\d{0,2})-(?:(?:A|B|C|D|EX|S|TR)-)?(?:\d{1,2})";
private const string StageNameRegex = @"(?:[a-z]{0,3})(?:\d{0,2})-(?:(?:A|B|C|D|EX|S|TR)-)?(?:\d{1,2})(\(Raid\))?";
/// <summary>
/// 为自动战斗列表匹配名字
@@ -262,7 +272,7 @@ namespace MaaWpfGui.ViewModels.UI
/// <returns>关卡名 or string.Empty</returns>
private static string FindStageName(params string[] names)
{
names = names.Where(str => !str.IsNullOrEmpty()).ToArray();
names = names.Where(str => !string.IsNullOrEmpty(str)).ToArray();
if (names.Length == 0)
{
return string.Empty;
@@ -270,7 +280,7 @@ namespace MaaWpfGui.ViewModels.UI
// 一旦有由小写字母、数字、'-'组成的name则视为关卡名直接使用
var directName = names.FirstOrDefault(name => name.ToLower().All(c => (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '-'));
if (!directName.IsNullOrEmpty())
if (!string.IsNullOrEmpty(directName))
{
return directName;
}
@@ -468,7 +478,7 @@ namespace MaaWpfGui.ViewModels.UI
return;
}
Dictionary<string, string> taskPairs = new Dictionary<string, string>();
Dictionary<string, string> taskPairs = new();
foreach (var file in dialog.FileNames)
{
var fileInfo = new FileInfo(file);
@@ -490,10 +500,10 @@ namespace MaaWpfGui.ViewModels.UI
return;
}
var fileName = fileInfo.Name.Substring(0, fileInfo.Name.Length - fileInfo.Extension.Length).Replace("突袭", "-Adverse");
var fileName = fileInfo.Name.Substring(0, fileInfo.Name.Length - fileInfo.Extension.Length);
var stageName = FindStageName(fileName);
if (stageName.IsNullOrEmpty())
if (string.IsNullOrEmpty(stageName))
{
AddLog($"invalid name to navigate: {fileName}[{fileInfo.FullName}]", UiLogColor.Error);
return;
@@ -526,7 +536,9 @@ namespace MaaWpfGui.ViewModels.UI
File.Copy(taskPair.Value, jsonPath, true);
}
var item = new CopilotItemViewModel(taskPair.Key, jsonPath)
var navigateName = taskPair.Key;
var isRaid = navigateName.EndsWith("(Raid)");
var item = new CopilotItemViewModel(taskPair.Key.Replace("(Raid)", string.Empty), jsonPath, isRaid)
{
Index = CopilotItemViewModels.Count,
};
@@ -705,10 +717,10 @@ namespace MaaWpfGui.ViewModels.UI
// ReSharper disable once UnusedMember.Global
public void AddCopilotTask()
{
var stageName = CopilotTaskName.Trim().Replace("突袭", "-Adverse");
if (!stageName.IsNullOrEmpty())
var stageName = CopilotTaskName.Trim();
if (!string.IsNullOrEmpty(stageName))
{
AddCopilotTaskToList(stageName);
AddCopilotTaskToList(stageName, false);
}
}
@@ -716,21 +728,16 @@ namespace MaaWpfGui.ViewModels.UI
// ReSharper disable once UnusedMember.Global
public void AddCopilotTask_Adverse()
{
var stageName = CopilotTaskName.Trim().Replace("突袭", "-Adverse");
if (!stageName.EndsWith("-Adverse"))
var stageName = CopilotTaskName.Trim();
if (!string.IsNullOrEmpty(stageName))
{
stageName += "-Adverse";
}
if (!stageName.IsNullOrEmpty())
{
AddCopilotTaskToList(stageName);
AddCopilotTaskToList(stageName, true);
}
}
private void AddCopilotTaskToList(string stageName)
private void AddCopilotTaskToList(string stageName, bool isRaid)
{
var jsonPath = $"{CopilotJsonDir}/{stageName}.json";
var cachePath = $"{CopilotJsonDir}/{stageName}" + (isRaid ? "(Raid)" : string.Empty) + ".json";
try
{
@@ -743,13 +750,13 @@ namespace MaaWpfGui.ViewModels.UI
try
{
if (jsonPath != (IsDataFromWeb ? TempCopilotFile : Filename))
if (cachePath != (IsDataFromWeb ? TempCopilotFile : Filename))
{
// 相同路径跳拷贝
File.Copy(IsDataFromWeb ? TempCopilotFile : Filename, jsonPath, true);
File.Copy(IsDataFromWeb ? TempCopilotFile : Filename, cachePath, true);
}
var item = new CopilotItemViewModel(stageName, jsonPath)
var item = new CopilotItemViewModel(stageName, cachePath, isRaid)
{
Index = CopilotItemViewModels.Count,
};
@@ -776,6 +783,7 @@ namespace MaaWpfGui.ViewModels.UI
["name"] = item.Name,
["file_path"] = item.FilePath,
["copilot_id"] = item.CopilotId,
["is_raid"] = item.IsRaid,
["is_checked"] = item.IsChecked,
}).ToList());
ConfigurationHelper.SetValue(ConfigurationKeys.CopilotTaskList, JsonConvert.SerializeObject(jArray));
@@ -928,7 +936,7 @@ namespace MaaWpfGui.ViewModels.UI
mUserAdditional.Add(new JObject
{
["name"] = match.Groups[1].Value.Trim(),
["skill"] = match.Groups[2].Value.IsNullOrEmpty() ? 0 : int.Parse(match.Groups[2].Value),
["skill"] = string.IsNullOrEmpty(match.Groups[2].Value) ? 0 : int.Parse(match.Groups[2].Value),
});
}
@@ -940,7 +948,7 @@ namespace MaaWpfGui.ViewModels.UI
foreach (var model in CopilotItemViewModels.Where(i => i.IsChecked))
{
_copilotIdList.Add(model.CopilotId);
ret &= Instances.AsstProxy.AsstStartCopilot(model.FilePath, Form, AddTrust, AddUserAdditional, mUserAdditional, UseCopilotList, model.Name.Replace("-Adverse", string.Empty), model.Name.Contains("-Adverse"), _taskType, Loop ? LoopTimes : 1, _useSanityPotion, false);
ret &= Instances.AsstProxy.AsstStartCopilot(model.FilePath, Form, AddTrust, AddUserAdditional, mUserAdditional, UseCopilotList, model.Name, model.IsRaid, _taskType, Loop ? LoopTimes : 1, _useSanityPotion, false);
startAny = true;
}

View File

@@ -197,6 +197,7 @@
x:Name="CopilotList"
Grid.Row="0"
Grid.ColumnSpan="4"
HorizontalContentAlignment="Stretch"
dd:DragDrop.IsDragSource="{Binding Idle}"
dd:DragDrop.IsDropTarget="{Binding Idle}"
hc:BorderElement.CornerRadius="4,4,0,0"
@@ -210,18 +211,24 @@
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!--<maa:TextBlock Text="{Binding ID}" />
<maa:TextBlock Text=". " />-->
<CheckBox
Grid.Column="0"
Content="{c:Binding Name}"
IsChecked="{Binding IsChecked}"
IsHitTestVisible="{Binding ElementName=CopilotList, Path=DataContext.Idle}" />
<Button
<TextBlock
Grid.Column="1"
MinWidth="35"
VerticalAlignment="Center"
Text="{DynamicResource CopilotTaskRaidStage}"
Visibility="{c:Binding IsRaid}" />
<Button
Grid.Column="2"
MinWidth="30"
hc:IconElement.Geometry="{StaticResource CloseGeometry}"
BorderThickness="0"
Command="{s:Action DeleteCopilotTask}"
@@ -326,8 +333,8 @@
Margin="0,10"
properties:AutoScroll.AutoScroll="True"
HorizontalScrollBarVisibility="Disabled"
PanningMode="VerticalOnly"
IsInertiaEnabled="True">
IsInertiaEnabled="True"
PanningMode="VerticalOnly">
<ItemsControl ItemsSource="{Binding Path=LogItemViewModels}">
<ItemsControl.ItemTemplate>
<DataTemplate>