From 4204391c4d9709c82e59f4ba741391f66f17e691 Mon Sep 17 00:00:00 2001 From: Asriel Camora Date: Sat, 22 Jun 2024 15:33:34 -0700 Subject: [PATCH] Extra checks for SolverRunning in macro editor --- Craftimizer/Craftimizer.json | 10 +++++----- Craftimizer/Windows/MacroEditor.cs | 31 ++++++++++++++++-------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/Craftimizer/Craftimizer.json b/Craftimizer/Craftimizer.json index ad7a7a2..206ba0c 100644 --- a/Craftimizer/Craftimizer.json +++ b/Craftimizer/Craftimizer.json @@ -3,7 +3,7 @@ "Name": "Craftimizer", "Punchline": "Simulate crafts, create computer-assisted macros, and get mid-craft suggestions from the comfort of your own game!", "Description": "Allows you to generate macros and simulate all sorts of crafts without having to open another app. Open your crafting log to get started!", - "RepoUrl": "https://github.com/WorkingRobot/craftimizer", + "RepoUrl": "https://github.com/WorkingRobot/Craftimizer", "InternalName": "Craftimizer", "ApplicableVersion": "any", "Tags": [ @@ -21,10 +21,10 @@ "CategoryTags": [ "Jobs" ], - "IconUrl": "https://git.camora.dev/asriel/craftimizer/raw/branch/main/icon.png", + "IconUrl": "https://git.camora.dev/asriel/Craftimizer/raw/branch/main/icon.png", "ImageUrls": [ - "https://git.camora.dev/asriel/craftimizer/raw/branch/main/Images/RecipeNote.png", - "https://git.camora.dev/asriel/craftimizer/raw/branch/main/Images/SynthHelper.png", - "https://git.camora.dev/asriel/craftimizer/raw/branch/main/Images/MacroEditor.png", + "https://git.camora.dev/asriel/Craftimizer/raw/branch/main/Images/RecipeNote.png", + "https://git.camora.dev/asriel/Craftimizer/raw/branch/main/Images/SynthHelper.png", + "https://git.camora.dev/asriel/Craftimizer/raw/branch/main/Images/MacroEditor.png", ] } diff --git a/Craftimizer/Windows/MacroEditor.cs b/Craftimizer/Windows/MacroEditor.cs index 23e6ef9..2c72d7b 100644 --- a/Craftimizer/Windows/MacroEditor.cs +++ b/Craftimizer/Windows/MacroEditor.cs @@ -953,7 +953,7 @@ public sealed class MacroEditor : Window, IDisposable { var actionBase = actions[i].Base(); var canUse = actionBase.CanUse(sim); - if (ImGui.ImageButton(actions[i].GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(imageSize), default, Vector2.One, 0, default, !canUse ? new(1, 1, 1, ImGui.GetStyle().DisabledAlpha) : Vector4.One)) + if (ImGui.ImageButton(actions[i].GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(imageSize), default, Vector2.One, 0, default, !canUse ? new(1, 1, 1, ImGui.GetStyle().DisabledAlpha) : Vector4.One) && !SolverRunning) AddStep(actions[i]); if (!canUse && (CharacterStats.Level < actionBase.Level || @@ -1223,23 +1223,26 @@ public sealed class MacroEditor : Window, IDisposable if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) ImGuiUtils.Tooltip($"{action.GetName(RecipeData!.ClassJob)}\n{actionBase.GetTooltip(CreateSim(lastState), true)}"); - using var _padding = ImRaii.PushStyle(ImGuiStyleVar.WindowPadding, Vector2.Zero); - using (var _source = ImRaii.DragDropSource()) + if (!SolverRunning) { - if (_source) + using var _padding = ImRaii.PushStyle(ImGuiStyleVar.WindowPadding, Vector2.Zero); + using (var _source = ImRaii.DragDropSource()) { - ImGuiExtras.SetDragDropPayload("macroAction", i); - ImGui.ImageButton(action.GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(imageSize)); + if (_source) + { + ImGuiExtras.SetDragDropPayload("macroAction", i); + ImGui.ImageButton(action.GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(imageSize)); + } } - } - using (var _target = ImRaii.DragDropTarget()) - { - if (_target) + using (var _target = ImRaii.DragDropTarget()) { - if (ImGuiExtras.AcceptDragDropPayload("macroAction", out int j)) - Macro.Move(j, i); - else if (ImGuiExtras.AcceptDragDropPayload("macroActionInsert", out ActionType newAction)) - Macro.Insert(i, newAction); + if (_target) + { + if (ImGuiExtras.AcceptDragDropPayload("macroAction", out int j)) + Macro.Move(j, i); + else if (ImGuiExtras.AcceptDragDropPayload("macroActionInsert", out ActionType newAction)) + Macro.Insert(i, newAction); + } } } lastState = state;