Skip to content

Commit

Permalink
Move macros instead of swapping
Browse files Browse the repository at this point in the history
  • Loading branch information
WorkingRobot committed Nov 18, 2023
1 parent d186c42 commit 9bb7646
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Craftimizer/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ public void SwapMacros(int i, int j)
OnMacroListChanged?.Invoke();
}

public void MoveMacro(int fromIdx, int toIdx)
{
var macro = macros[fromIdx];
macros.RemoveAt(fromIdx);
macros.Insert(toIdx, macro);
Save();
OnMacroListChanged?.Invoke();
}

public void Save() =>
Service.PluginInterface.SavePluginConfig(this);
}
2 changes: 1 addition & 1 deletion Craftimizer/Windows/MacroList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public override void Draw()
if (_target)
{
if (ImGuiExtras.AcceptDragDropPayload("macroListItem", out int j))
Service.Configuration.SwapMacros(i, j);
Service.Configuration.MoveMacro(j, i);
}
}
}
Expand Down

1 comment on commit 9bb7646

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 9bb7646 Previous: a8c3f34 Ratio
Craftimizer.Benchmark.Bench.Solve(State: 3484F719, Config: F84E5413) 1635056126.6666667 ns (± 4665616.124902732)
Craftimizer.Benchmark.Bench.Solve(State: 3484F719, Config: F84E5413) 1045010180 ns (± 8096552.770531419)
Craftimizer.Benchmark.Bench.Solve(State: 6248FEF0, Config: F84E5413) 1595605750 ns (± 5096393.495668511)
Craftimizer.Benchmark.Bench.Solve(State: 6248FEF0, Config: F84E5413) 1061056164.2857143 ns (± 4547327.45392739)

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.