Fix copying macro to clipboard, and using /nextmacro

This commit is contained in:
Asriel Camora
2023-10-24 01:02:21 -07:00
parent 3836fbef10
commit 889d07433c
+7 -7
View File
@@ -27,7 +27,7 @@ public static class MacroCopy
var config = Service.Configuration.MacroCopy; var config = Service.Configuration.MacroCopy;
var macros = new List<string>(); var macros = new List<string>();
var s = new List<string>(); var s = new List<string>();
foreach(var action in actions) for (var i = 0; i < actions.Count; ++i)
{ {
if (s.Count == 0) if (s.Count == 0)
{ {
@@ -35,18 +35,18 @@ public static class MacroCopy
s.Add("/mlock"); s.Add("/mlock");
} }
s.Add(GetActionCommand(action, config)); s.Add(GetActionCommand(actions[i], config));
if (config.Type == MacroCopyConfiguration.CopyType.CopyToMacro || !config.CombineMacro) if (i != actions.Count - 1 && (config.Type == MacroCopyConfiguration.CopyType.CopyToMacro || !config.CombineMacro))
{ {
if (s.Count == MacroSize - 1) if (s.Count == MacroSize - 1)
{ {
if (GetEndCommand(macros.Count, true, config) is { } endCommand) if (GetEndCommand(macros.Count, false, config) is { } endCommand)
s.Add(endCommand); s.Add(endCommand);
} }
if (s.Count == MacroSize) if (s.Count == MacroSize)
{ {
macros.Add(string.Join("\n", s)); macros.Add(string.Join(Environment.NewLine, s));
s.Clear(); s.Clear();
} }
} }
@@ -55,7 +55,7 @@ public static class MacroCopy
{ {
if (GetEndCommand(macros.Count, true, config) is { } endCommand) if (GetEndCommand(macros.Count, true, config) is { } endCommand)
s.Add(endCommand); s.Add(endCommand);
macros.Add(string.Join("\n", s)); macros.Add(string.Join(Environment.NewLine, s));
} }
switch (config.Type) switch (config.Type)
@@ -146,7 +146,7 @@ public static class MacroCopy
private static void CopyToClipboard(List<string> macros, MacroCopyConfiguration config) private static void CopyToClipboard(List<string> macros, MacroCopyConfiguration config)
{ {
ImGui.SetClipboardText(string.Join("\n\n", macros)); ImGui.SetClipboardText(string.Join(Environment.NewLine + Environment.NewLine, macros));
Service.PluginInterface.UiBuilder.AddNotification(macros.Count > 1 ? "Copied macro to clipboard." : $"Copied {macros.Count} macros to clipboard.", "Craftimizer Macro Copied", NotificationType.Success); Service.PluginInterface.UiBuilder.AddNotification(macros.Count > 1 ? "Copied macro to clipboard." : $"Copied {macros.Count} macros to clipboard.", "Craftimizer Macro Copied", NotificationType.Success);
} }
} }