Skip to content

Commit 6e15fa6

Browse files
committed
fix wrong macro pickup during import
1 parent 5ba4bde commit 6e15fa6

File tree

2 files changed

+45
-22
lines changed

2 files changed

+45
-22
lines changed

Myslot.lua

+38-22
Original file line numberDiff line numberDiff line change
@@ -565,11 +565,24 @@ function MySlot:RecoverData(msg, opt)
565565
end
566566
-- }}}
567567

568+
local slotBucket = {}
568569

569570
-- {{{ Macro
570-
-- cache macro
571571
local macro = {}
572-
MySlot:Clear("MACRO", opt.clearOpt.ignoreMacros)
572+
573+
for _, s in pairs(msg.slot or {}) do
574+
local slotId = s.id
575+
local slotType = _MySlot.Slot.SlotType[s.type]
576+
local index = s.index
577+
578+
if slotType == MYSLOT_MACRO then
579+
if macro[index] then
580+
table.insert(macro[index], slotId)
581+
else
582+
macro[index] = {slotId}
583+
end
584+
end
585+
end
573586

574587
for _, m in pairs(msg.macro or {}) do
575588
local macroId = m.id
@@ -585,22 +598,29 @@ function MySlot:RecoverData(msg, opt)
585598
["body"] = body,
586599
}
587600

588-
if not opt.actionOpt.ignoreMacros["ACCOUNT"] and macroId <= MAX_ACCOUNT_MACROS then
589-
macro[macroId] = self:FindOrCreateMacro(info)
601+
local newid = nil
602+
603+
if (not opt.actionOpt.ignoreMacros["ACCOUNT"] and macroId <= MAX_ACCOUNT_MACROS)
604+
or (not opt.actionOpt.ignoreMacros["CHARACTOR"] and macroId > MAX_ACCOUNT_MACROS)
605+
then
606+
newid = self:FindOrCreateMacro(info)
590607
end
591608

592-
if not opt.actionOpt.ignoreMacros["CHARACTOR"] and macroId > MAX_ACCOUNT_MACROS then
593-
macro[macroId] = self:FindOrCreateMacro(info)
609+
if not newid then
610+
newid = self:FindMacro(info)
594611
end
595612

596-
if not macro[macroId] then
597-
macro[macroId] = self:FindMacro(info)
613+
if newid then
614+
for _, slotId in pairs(macro[macroId] or {}) do
615+
PickupMacro(newid)
616+
PlaceAction(slotId)
617+
end
618+
else
619+
MySlot:Print(L["Ignore unknown macro [id=%s]"]:format(macroId))
598620
end
599621
end
600622
-- }}} Macro
601623

602-
MySlot:Clear("ACTION", opt.clearOpt.ignoreActionBars)
603-
local slotBucket = {}
604624

605625
for _, s in pairs(msg.slot or {}) do
606626
local slotId = s.id
@@ -644,16 +664,16 @@ function MySlot:RecoverData(msg, opt)
644664
end
645665
elseif slotType == MYSLOT_ITEM then
646666
PickupItem(index)
647-
elseif slotType == MYSLOT_MACRO then
648-
local macroid = macro[index]
667+
-- elseif slotType == MYSLOT_MACRO then
668+
-- local macroid = macro[index]
649669

650-
if not macroid then
651-
MySlot:Print(L["Ignore unknown macro [id=%s]"]:format(index))
652-
end
670+
-- if not macroid then
671+
-- MySlot:Print(L["Ignore unknown macro [id=%s]"]:format(index))
672+
-- end
653673

654-
if curType ~= MYSLOT_MACRO or curIndex ~= macroid then
655-
PickupMacro(macroid)
656-
end
674+
-- if curType ~= MYSLOT_MACRO or curIndex ~= macroid then
675+
-- PickupMacro(macroid)
676+
-- end
657677
elseif slotType == MYSLOT_SUMMONPET and strindex and strindex ~= curIndex then
658678
C_PetJournal.PickupPet(strindex, false)
659679
if not GetCursorInfo() then
@@ -695,10 +715,6 @@ function MySlot:RecoverData(msg, opt)
695715
end
696716
end
697717

698-
if opt.clearOpt.ignoreBinding then
699-
MySlot:Clear("BINDING")
700-
end
701-
702718
if not opt.actionOpt.ignoreBinding then
703719

704720
for _, b in pairs(msg.bind or {}) do

gui.lua

+7
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,13 @@ do
341341

342342
StaticPopupDialogs["MYSLOT_MSGBOX"].OnAccept = function()
343343
StaticPopup_Hide("MYSLOT_MSGBOX")
344+
345+
MySlot:Clear("MACRO", clearOpt.ignoreMacros)
346+
MySlot:Clear("ACTION", clearOpt.ignoreActionBars)
347+
if clearOpt.ignoreBinding then
348+
MySlot:Clear("BINDING")
349+
end
350+
344351
MySlot:RecoverData(msg, {
345352
actionOpt = actionOpt,
346353
clearOpt = clearOpt,

0 commit comments

Comments
 (0)