Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: crash when add action in Actions in List.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Oct 23, 2023
1 parent 98aee14 commit 00b5549
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 49 deletions.
31 changes: 17 additions & 14 deletions RotationSolver.Basic/Configuration/OtherConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
68 changes: 33 additions & 35 deletions RotationSolver/UI/RotationConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1813,17 +1813,17 @@ private static void DrawActionsStatuses()
}

static string _statusSearching = string.Empty;
private static async void DrawStatusList(string name, HashSet<uint> statuses, Status[] allStatus)
private static void DrawStatusList(string name, HashSet<uint> 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)));
Expand Down Expand Up @@ -1868,7 +1868,7 @@ private static async void DrawStatusList(string name, HashSet<uint> statuses, St
if (removeId != 0)
{
statuses.Remove(removeId);
await OtherConfiguration.Save();
OtherConfiguration.Save();
}
}

Expand Down Expand Up @@ -1949,41 +1949,12 @@ private static void DrawListActions()
}

private static string _actionSearching = string.Empty;
private static async void DrawActionsList(string name, HashSet<uint> actions)
private static void DrawActionsList(string name, HashSet<uint> 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);
Expand All @@ -2009,7 +1980,34 @@ private static async void DrawActionsList(string name, HashSet<uint> 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();
}
}
}
}
}
}

Expand Down

0 comments on commit 00b5549

Please sign in to comment.