Skip to content

Commit

Permalink
Add drag & drop for macro editor (both action hotbars & moving actions)
Browse files Browse the repository at this point in the history
  • Loading branch information
WorkingRobot committed Nov 18, 2023
1 parent 4854b92 commit 65b41f5
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion Craftimizer/Windows/MacroEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,16 @@ private void DrawActionHotbars()
}
if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
ImGui.SetTooltip($"{actions[i].GetName(RecipeData!.ClassJob)}\n{actionBase.GetTooltip(sim, true)}");

using var _padding = ImRaii.PushStyle(ImGuiStyleVar.WindowPadding, Vector2.Zero);
using (var _source = ImRaii.DragDropSource())
{
if (_source)
{
ImGuiExtras.SetDragDropPayload("macroActionInsert", actions[i]);
ImGui.ImageButton(actions[i].GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(imageSize));
}
}
}
else
ImGui.Dummy(new(imageSize));
Expand Down Expand Up @@ -1207,8 +1217,26 @@ private void DrawMacro()
ImGui.PopClipRect();
}
if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled))
{
ImGui.SetTooltip($"{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 (_source)
{
ImGuiExtras.SetDragDropPayload("macroAction", i);
ImGui.ImageButton(action.GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(imageSize));
}
}
using (var _target = ImRaii.DragDropTarget())
{
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;
}
Expand Down

0 comments on commit 65b41f5

Please sign in to comment.