Skip to content

Commit 51a7994

Browse files
Merge pull request #151 from niechy/master
feat: 切换控制器时资源不兼容自动切换并提示
2 parents a484208 + 455ee63 commit 51a7994

5 files changed

Lines changed: 39 additions & 2 deletions

File tree

MFAAvalonia/Assets/Localization/Strings.en-US.resx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,14 @@
14061406
<data name="FontScaleValue" xml:space="preserve">
14071407
<value>{0}%</value>
14081408
</data>
1409+
<data name="ResourceAutoSwitched" xml:space="preserve">
1410+
<value>Resource Auto-Switched</value>
1411+
</data>
1412+
<data name="ResourceNotSupportController" xml:space="preserve">
1413+
<value>Current controller {1} does not support resource {0}, auto-switched to {2}. Please check resource settings.</value>
1414+
</data>
1415+
1416+
14091417
<data name="ResourcePresetConfig" xml:space="preserve">
14101418
<value>Resource Preset Config</value>
14111419
</data>

MFAAvalonia/Assets/Localization/Strings.resx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,13 @@
14131413
<data name="FontScaleValue" xml:space="preserve">
14141414
<value>{0}%</value>
14151415
</data>
1416+
<data name="ResourceAutoSwitched" xml:space="preserve">
1417+
<value>资源已自动切换</value>
1418+
</data>
1419+
<data name="ResourceNotSupportController" xml:space="preserve">
1420+
<value>当前控制器 {1} 不支持资源 {0},已自动切换为 {2},请检查资源设置</value>
1421+
</data>
1422+
14161423
<data name="ResourcePresetConfig" xml:space="preserve">
14171424
<value>资源预设配置</value>
14181425
</data>

MFAAvalonia/Assets/Localization/Strings.zh-Hant.resx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,13 @@
13981398
<data name="ScheduleMonthlyDaySuffix" xml:space="preserve">
13991399
<value>號</value>
14001400
</data>
1401+
<data name="ResourceAutoSwitched" xml:space="preserve">
1402+
<value>資源已自動切換</value>
1403+
</data>
1404+
<data name="ResourceNotSupportController" xml:space="preserve">
1405+
<value>當前控制器 {1} 不支援資源 {0},已自動切換為 {2},請檢查資源設定</value>
1406+
</data>
1407+
14011408
<data name="ResourcePresetConfig" xml:space="preserve">
14021409
<value>資源預設配置</value>
14031410
</data>

MFAAvalonia/Helper/LangKeys.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,8 @@ public static class LangKeys
471471
public static readonly string FontScaleTitle = "FontScaleTitle";
472472
public static readonly string FontScaleDescription = "FontScaleDescription";
473473
public static readonly string FontScaleValue = "FontScaleValue";
474+
public static readonly string ResourceAutoSwitched = "ResourceAutoSwitched";
475+
public static readonly string ResourceNotSupportController = "ResourceNotSupportController";
474476
public static readonly string ResourcePresetConfig = "ResourcePresetConfig";
475477
}
476478

MFAAvalonia/ViewModels/Pages/TaskQueueViewModel.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,10 +668,23 @@ public void UpdateResourcesForController()
668668
// 更新资源列表
669669
CurrentResources = new ObservableCollection<MaaInterface.MaaInterfaceResource>(filteredResources);
670670

671-
// 如果当前选中的资源不在过滤后的列表中,则选择第一个
671+
// 如果当前选中的资源不在过滤后的列表中,则选择第一个并提示用户
672672
if (CurrentResources.Count > 0 && CurrentResources.All(r => r.Name != CurrentResource))
673673
{
674-
CurrentResource = CurrentResources[0].Name ?? "Default";
674+
var oldResource = CurrentResource;
675+
var newResource = CurrentResources[0].Name ?? "Default";
676+
CurrentResource = newResource;
677+
678+
// 仅当旧资源非空时才提示(避免首次加载时提示)
679+
if (!string.IsNullOrEmpty(oldResource))
680+
{
681+
var controllerDisplayName = currentControllerName ?? CurrentController.ToResourceKey().ToLocalization();
682+
ToastHelper.Warn(
683+
LangKeys.ResourceAutoSwitched.ToLocalization(),
684+
LangKeys.ResourceNotSupportController.ToLocalizationFormatted(
685+
false, oldResource, controllerDisplayName, newResource),
686+
6);
687+
}
675688
}
676689
}
677690

0 commit comments

Comments
 (0)