Skip to content

Commit

Permalink
perf: 优化数据绑定逻辑,减少 AsstProxy 逻辑处理
Browse files Browse the repository at this point in the history
  • Loading branch information
ABA2396 committed Jun 19, 2024
1 parent 3efe3cc commit ab484ff
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/MaaWpfGui/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,5 @@ csharp_preserve_single_line_blocks = true
# SA1010: Opening square brackets should be spaced correctly
dotnet_diagnostic.SA1010.severity = silent
# Code inspection: Incorrect line breaks (around parenthesis)
resharper_bad_parens_line_breaks_highlighting = none
resharper_bad_parens_line_breaks_highlighting = none
resharper_bad_braces_spaces_highlighting = none
6 changes: 3 additions & 3 deletions src/MaaWpfGui/Helper/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ public WindowManager(IViewManager viewManager, Func<IMessageBoxViewModel> messag

private readonly bool _loadWindowPlacement = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.LoadWindowPlacement, bool.TrueString));
private readonly bool _saveWindowPlacement = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.SaveWindowPlacement, bool.TrueString));
private readonly bool _minimizeDirectly = bool.Parse(ConfigurationHelper.GetValue(ConfigurationKeys.MinimizeDirectly, bool.FalseString));
private readonly bool _minimizeToTray = bool.Parse(ConfigurationHelper.GetValue(ConfigurationKeys.MinimizeToTray, bool.FalseString));
private readonly bool _minimizeDirectly = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.MinimizeDirectly, bool.FalseString));
private readonly bool _minimizeToTray = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.MinimizeToTray, bool.FalseString));

/// <summary>
/// Center other windows in MaaWpfGui.RootView
/// </summary>
private static void MoveWindowToDisplay(Window window)
{
var mainWindow = Application.Current.MainWindow;
if (!(mainWindow is { WindowState: WindowState.Normal }))
if (mainWindow is not { WindowState: WindowState.Normal })
{
return;
}
Expand Down
10 changes: 5 additions & 5 deletions src/MaaWpfGui/Main/AsstProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2300,7 +2300,7 @@ public bool AsstAppendRoguelike(
["investment_enabled"] = false,
};

if (mode == 1 || investmentEnabled)
if (investmentEnabled)
{
taskParams["investment_enabled"] = true;
taskParams["investment_with_more_score"] = investmentWithMoreScore;
Expand All @@ -2323,14 +2323,14 @@ public bool AsstAppendRoguelike(
taskParams["core_char"] = coreChar;
}

taskParams["start_with_elite_two"] = mode == 4 && theme != "Phantom" && startWithEliteTwo;
taskParams["only_start_with_elite_two"] = mode == 4 && theme != "Phantom" && startWithEliteTwo && onlyStartWithEliteTwo;
if (mode == 4 && theme == "Sami" && roguelike3FirstFloorFoldartal && roguelike3StartFloorFoldartal.Length > 0)
taskParams["start_with_elite_two"] = startWithEliteTwo;
taskParams["only_start_with_elite_two"] = onlyStartWithEliteTwo;
if (roguelike3FirstFloorFoldartal && roguelike3StartFloorFoldartal.Length > 0)
{
taskParams["first_floor_foldartal"] = roguelike3StartFloorFoldartal;
}

if (mode == 4 && theme == "Sami" && roguelike3NewSquad2StartingFoldartal && roguelike3NewSquad2StartingFoldartals.Length > 0)
if (roguelike3NewSquad2StartingFoldartal && roguelike3NewSquad2StartingFoldartals.Length > 0)
{
taskParams["start_foldartal_list"] = new JArray(roguelike3NewSquad2StartingFoldartals.Trim().Split(';', ';').Where(i => !string.IsNullOrEmpty(i)).Take(3));
}
Expand Down
2 changes: 1 addition & 1 deletion src/MaaWpfGui/Models/TaskSettingVisibilityInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public bool Guide

#region 双入口设置可见性

private bool _customInfrastPlanShowInFightSettings = bool.Parse(ConfigurationHelper.GetValue(ConfigurationKeys.CustomInfrastPlanShowInFightSettings, false.ToString()));
private bool _customInfrastPlanShowInFightSettings = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.CustomInfrastPlanShowInFightSettings, bool.FalseString));

public bool CustomInfrastPlanShowInFightSettings
{
Expand Down
3 changes: 2 additions & 1 deletion src/MaaWpfGui/ViewModels/UI/AnnouncementViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// but WITHOUT ANY WARRANTY
// </copyright>

using System;
using System.Threading.Tasks;
using MaaWpfGui.Constants;
using MaaWpfGui.Helper;
Expand Down Expand Up @@ -41,7 +42,7 @@ private set
}
}

private bool _doNotRemindThisAnnouncementAgain = bool.Parse(ConfigurationHelper.GetValue(ConfigurationKeys.DoNotRemindThisAnnouncementAgain, false.ToString()));
private bool _doNotRemindThisAnnouncementAgain = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.DoNotRemindThisAnnouncementAgain, bool.FalseString));

public bool DoNotRemindThisAnnouncementAgain
{
Expand Down
2 changes: 1 addition & 1 deletion src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ public bool UseSanityPotion
set => SetAndNotify(ref _useSanityPotion, value);
}

private bool _addUserAdditional = bool.Parse(ConfigurationHelper.GetValue(ConfigurationKeys.CopilotAddUserAdditional, false.ToString()));
private bool _addUserAdditional = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.CopilotAddUserAdditional, bool.FalseString));

/// <summary>
/// Gets or sets a value indicating whether to use auto-formation.
Expand Down
13 changes: 11 additions & 2 deletions src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,8 +1300,17 @@ private void SetFightRemainingSanityParams()
private void SetInfrastParams()
{
var order = Instances.SettingsViewModel.GetInfrastOrderList();
Instances.AsstProxy.AsstSetInfrastTaskParams(order.ToArray(), Instances.SettingsViewModel.UsesOfDrones, Instances.SettingsViewModel.ContinueTraining, Instances.SettingsViewModel.DormThreshold / 100.0, Instances.SettingsViewModel.DormFilterNotStationedEnabled, Instances.SettingsViewModel.DormTrustEnabled,
Instances.SettingsViewModel.OriginiumShardAutoReplenishment, Instances.SettingsViewModel.CustomInfrastEnabled, Instances.SettingsViewModel.CustomInfrastFile, CustomInfrastPlanIndex);
Instances.AsstProxy.AsstSetInfrastTaskParams(
order.ToArray(),
Instances.SettingsViewModel.UsesOfDrones,
Instances.SettingsViewModel.ContinueTraining,
Instances.SettingsViewModel.DormThreshold / 100.0,
Instances.SettingsViewModel.DormFilterNotStationedEnabled,
Instances.SettingsViewModel.DormTrustEnabled,
Instances.SettingsViewModel.OriginiumShardAutoReplenishment,
Instances.SettingsViewModel.CustomInfrastEnabled,
Instances.SettingsViewModel.CustomInfrastFile,
CustomInfrastPlanIndex);
}

private bool AppendInfrast()
Expand Down

0 comments on commit ab484ff

Please sign in to comment.