diff --git a/RotationSolver.Basic/Configuration/OtherConfiguration.cs b/RotationSolver.Basic/Configuration/OtherConfiguration.cs index b1bc6fd5e..c39447c88 100644 --- a/RotationSolver.Basic/Configuration/OtherConfiguration.cs +++ b/RotationSolver.Basic/Configuration/OtherConfiguration.cs @@ -99,20 +99,23 @@ public static void Init() Task.Run(() => InitOne(ref RotationSolverRecord, nameof(RotationSolverRecord), false)); } - public static async Task Save() - { - await SaveDangerousStatus(); - await SaveInvincibleStatus(); - await SaveNoHostileNames(); - await SaveAnimationLockTime(); - await SaveHostileCastingArea(); - await SaveHostileCastingTank(); - await SaveBeneficialPositions(); - await SaveRotationSolverRecord(); - await SaveNoProvokeNames(); - await SaveActionAOECounts(); - await SaveActionTTK(); - await SaveActionHealRatio(); + public static Task Save() + { + return Task.Run(async () => + { + await SaveDangerousStatus(); + await SaveInvincibleStatus(); + await SaveNoHostileNames(); + await SaveAnimationLockTime(); + await SaveHostileCastingArea(); + await SaveHostileCastingTank(); + await SaveBeneficialPositions(); + await SaveRotationSolverRecord(); + await SaveNoProvokeNames(); + await SaveActionAOECounts(); + await SaveActionTTK(); + await SaveActionHealRatio(); + }); } public static Task SaveActionHealRatio() diff --git a/RotationSolver/UI/RotationConfigWindow.cs b/RotationSolver/UI/RotationConfigWindow.cs index 4f87c1cb4..1171adced 100644 --- a/RotationSolver/UI/RotationConfigWindow.cs +++ b/RotationSolver/UI/RotationConfigWindow.cs @@ -1813,17 +1813,17 @@ private static void DrawActionsStatuses() } static string _statusSearching = string.Empty; - private static async void DrawStatusList(string name, HashSet statuses, Status[] allStatus) + private static void DrawStatusList(string name, HashSet statuses, Status[] allStatus) { uint removeId = 0; uint notLoadId = 10100; var popupId = "Rotation Solver Popup" + name; - StatusPopUp(popupId, allStatus, ref _statusSearching, async status => + StatusPopUp(popupId, allStatus, ref _statusSearching, status => { statuses.Add(status.RowId); - await OtherConfiguration.Save(); + OtherConfiguration.Save(); }, notLoadId); var count = Math.Max(1, (int)MathF.Floor(ImGui.GetColumnWidth() / (24 * Scale + ImGui.GetStyle().ItemSpacing.X))); @@ -1868,7 +1868,7 @@ private static async void DrawStatusList(string name, HashSet statuses, St if (removeId != 0) { statuses.Remove(removeId); - await OtherConfiguration.Save(); + OtherConfiguration.Save(); } } @@ -1949,41 +1949,12 @@ private static void DrawListActions() } private static string _actionSearching = string.Empty; - private static async void DrawActionsList(string name, HashSet actions) + private static void DrawActionsList(string name, HashSet actions) { uint removeId = 0; var popupId = "Rotation Solver Action Popup" + name; - using var popup = ImRaii.Popup(popupId); - if (popup) - { - ImGui.SetNextItemWidth(200 * Scale); - ImGui.InputTextWithHint("##Searching the action pop up", LocalizationManager.RightLang.ConfigWindow_List_ActionNameOrId, ref _actionSearching, 128); - - ImGui.Spacing(); - - using var child = ImRaii.Child("Rotation Solver Add action", new Vector2(-1, 400 * Scale)); - if (child) - { - foreach (var action in AllActions.OrderByDescending(s =>Similarity(s.Name + " " + s.RowId.ToString(), _actionSearching))) - { - var selected = ImGui.Selectable($"{action.Name} ({action.RowId})"); - if (ImGui.IsItemHovered()) - { - ImguiTooltips.ShowTooltip($"{action.Name} ({action.RowId})"); - if(selected) - { - actions.Add(action.RowId); - await OtherConfiguration.Save(); - ImGui.CloseCurrentPopup(); - } - } - } - } - } - - if (ImGui.Button(LocalizationManager.RightLang.ConfigWindow_List_AddAction + "##" + name)) { if (!ImGui.IsPopupOpen(popupId)) ImGui.OpenPopup(popupId); @@ -2009,7 +1980,34 @@ private static async void DrawActionsList(string name, HashSet actions) if (removeId != 0) { actions.Remove(removeId); - await OtherConfiguration.Save(); + OtherConfiguration.Save(); + } + + using var popup = ImRaii.Popup(popupId); + if (popup) + { + ImGui.SetNextItemWidth(200 * Scale); + ImGui.InputTextWithHint("##Searching the action pop up", LocalizationManager.RightLang.ConfigWindow_List_ActionNameOrId, ref _actionSearching, 128); + + ImGui.Spacing(); + + using var child = ImRaii.Child("Rotation Solver Add action", new Vector2(-1, 400 * Scale)); + if (child) + { + foreach (var action in AllActions.OrderByDescending(s => Similarity(s.Name + " " + s.RowId.ToString(), _actionSearching))) + { + var selected = ImGui.Selectable($"{action.Name} ({action.RowId})"); + if (ImGui.IsItemHovered()) + { + ImguiTooltips.ShowTooltip($"{action.Name} ({action.RowId})"); + if (selected) + { + actions.Add(action.RowId); + OtherConfiguration.Save(); ImGui.CloseCurrentPopup(); + } + } + } + } } }