@@ -16,7 +16,7 @@ local MYSLOT_VER = 42
16
16
-- TWW Beta Compat code (fix and cleanup below later)
17
17
local GetNumSpellTabs = C_SpellBook and C_SpellBook .GetNumSpellBookSkillLines or _G .GetNumSpellTabs
18
18
local GetSpellTabInfo = (C_SpellBook and C_SpellBook .GetSpellBookSkillLineInfo ) and function (index )
19
- local skillLineInfo = C_SpellBook .GetSpellBookSkillLineInfo (index );
19
+ local skillLineInfo = C_SpellBook .GetSpellBookSkillLineInfo (index )
20
20
if skillLineInfo then
21
21
return skillLineInfo .name ,
22
22
skillLineInfo .iconID ,
@@ -25,14 +25,15 @@ local GetSpellTabInfo = (C_SpellBook and C_SpellBook.GetSpellBookSkillLineInfo)
25
25
skillLineInfo .isGuild ,
26
26
skillLineInfo .offSpecID ,
27
27
skillLineInfo .shouldHide ,
28
- skillLineInfo .specID ;
28
+ skillLineInfo .specID
29
29
end
30
30
end or _G .GetSpellTabInfo
31
31
local PickupSpell = C_Spell and C_Spell .PickupSpell or _G .PickupSpell
32
32
local PickupItem = C_Item and C_Item .PickupItem or _G .PickupItem
33
33
local GetSpellInfo = C_Spell and C_Spell .GetSpellName or _G .GetSpellInfo
34
34
local GetSpellLink = C_Spell and C_Spell .GetSpellLink or _G .GetSpellLink
35
35
local GetSpellBookItemInfo = C_SpellBook and C_SpellBook .GetSpellBookItemType or _G .GetSpellBookItemInfo
36
+ local PickupSpellBookItem = C_SpellBook and C_SpellBook .PickupSpellBookItem or _G .PickupSpellBookItem
36
37
-- TWW Beta Compat End
37
38
38
39
-- local MYSLOT_IS_DEBUG = true
@@ -107,6 +108,59 @@ local function TableToString(s)
107
108
return table.concat (t )
108
109
end
109
110
111
+ local function CreateSpellOverrideMap ()
112
+ local spellOverride = {}
113
+
114
+ if C_SpellBook and C_SpellBook .GetNumSpellBookSkillLines then
115
+ -- 11.0 only
116
+ for skillLineIndex = 1 , C_SpellBook .GetNumSpellBookSkillLines () do
117
+ local skillLineInfo = C_SpellBook .GetSpellBookSkillLineInfo (skillLineIndex )
118
+ for i = 1 , skillLineInfo .numSpellBookItems do
119
+ local spellIndex = skillLineInfo .itemIndexOffset + i
120
+ local _ , spellId = C_SpellBook .GetSpellBookItemType (spellIndex , Enum .SpellBookSpellBank .Player )
121
+ if spellId then
122
+ local newid = C_Spell .GetOverrideSpell (spellId )
123
+ if newid ~= spellId then
124
+ spellOverride [newid ] = spellId
125
+ end
126
+ end
127
+ end
128
+ end
129
+
130
+ local isInspect = false
131
+ for specIndex = 1 , GetNumSpecGroups (isInspect ) do
132
+ for tier = 1 , MAX_TALENT_TIERS do
133
+ for column = 1 , NUM_TALENT_COLUMNS do
134
+ local spellId = select (6 , GetTalentInfo (tier , column , specIndex ))
135
+ if spellId then
136
+ local newid = C_Spell .GetOverrideSpell (spellId )
137
+ if newid ~= spellId then
138
+ spellOverride [newid ] = spellId
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
144
+
145
+ for pvpTalentSlot = 1 , 3 do
146
+ local slotInfo = C_SpecializationInfo .GetPvpTalentSlotInfo (pvpTalentSlot )
147
+ if slotInfo ~= nil then
148
+ for i , pvpTalentID in ipairs (slotInfo .availableTalentIDs ) do
149
+ local spellId = select (6 , GetPvpTalentInfoByID (pvpTalentID ))
150
+ if spellId then
151
+ local newid = C_Spell .GetOverrideSpell (spellId )
152
+ if newid ~= spellId then
153
+ spellOverride [newid ] = spellId
154
+ end
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
160
+
161
+ return spellOverride
162
+ end
163
+
110
164
function MySlot :Print (msg )
111
165
DEFAULT_CHAT_FRAME :AddMessage (" |CFFFF0000<|r|CFFFFD100Myslot|r|CFFFF0000>|r" .. (msg or " nil" ))
112
166
end
@@ -121,7 +175,7 @@ function MySlot:GetMacroInfo(macroId)
121
175
return nil
122
176
end
123
177
124
- iconTexture = gsub (strupper (iconTexture or " INV_Misc_QuestionMark" ), " INTERFACE\\ ICONS\\ " , " " );
178
+ iconTexture = gsub (strupper (iconTexture or " INV_Misc_QuestionMark" ), " INTERFACE\\ ICONS\\ " , " " )
125
179
126
180
local msg = _MySlot .Macro ()
127
181
msg .id = macroId
@@ -322,10 +376,18 @@ function MySlot:Export(opt)
322
376
end
323
377
324
378
msg .slot = {}
379
+ -- TODO move to GetActionInfo
380
+ local spellOverride = CreateSpellOverrideMap ()
381
+
325
382
for i = 1 , MYSLOT_MAX_ACTIONBAR do
326
383
if not opt .ignoreActionBars [math.ceil (i / 12 )] then
327
384
local m = self :GetActionInfo (i )
328
385
if m then
386
+ if m .type == ' SPELL' then
387
+ if spellOverride [m .index ] then
388
+ m .index = spellOverride [m .index ]
389
+ end
390
+ end
329
391
msg .slot [# msg .slot + 1 ] = m
330
392
end
331
393
end
@@ -372,22 +434,27 @@ function MySlot:Export(opt)
372
434
s = " # --------------------" .. MYSLOT_LINE_SEP .. s
373
435
s = " # " .. L [
" Feedback" ]
.. " [email protected] " .. MYSLOT_LINE_SEP .. s
374
436
s = " # " .. MYSLOT_LINE_SEP .. s
375
- s = " # " .. LEVEL .. " :" .. UnitLevel (" player" ) .. MYSLOT_LINE_SEP .. s
437
+ s = " # " .. LEVEL .. " : " .. UnitLevel (" player" ) .. MYSLOT_LINE_SEP .. s
376
438
if talent then
377
- s = " # " .. TALENTS .. " :" .. talent .. MYSLOT_LINE_SEP .. s
439
+ s = " # " .. TALENTS .. " : " .. talent .. MYSLOT_LINE_SEP .. s
378
440
end
379
441
if GetSpecialization then
380
442
s = " # " ..
381
443
SPECIALIZATION ..
382
- " :" ..
444
+ " : " ..
383
445
(GetSpecialization () and select (2 , GetSpecializationInfo (GetSpecialization ())) or NONE_CAPS ) ..
384
446
MYSLOT_LINE_SEP .. s
385
447
end
386
- s = " # " .. CLASS .. " :" .. UnitClass (" player" ) .. MYSLOT_LINE_SEP .. s
387
- s = " # " .. PLAYER .. " :" .. UnitName (" player" ) .. MYSLOT_LINE_SEP .. s
388
- s = " # " .. L [" Time" ] .. " :" .. date () .. MYSLOT_LINE_SEP .. s
389
- s = " # Wow (V" .. GetBuildInfo () .. " )" .. MYSLOT_LINE_SEP .. s
390
- s = " # Myslot (https://myslot.net)" .. MYSLOT_LINE_SEP .. s
448
+ s = " # " .. CLASS .. " : " .. UnitClass (" player" ) .. MYSLOT_LINE_SEP .. s
449
+ s = " # " .. PLAYER .. " : " .. UnitName (" player" ) .. MYSLOT_LINE_SEP .. s
450
+ s = " # " .. L [" Time" ] .. " : " .. date () .. MYSLOT_LINE_SEP .. s
451
+
452
+ if GetAddOnMetadata then
453
+ s = " # Addon Version: " .. GetAddOnMetadata (" Myslot" , " Version" ) .. MYSLOT_LINE_SEP .. s
454
+ end
455
+
456
+ s = " # Wow Version: " .. GetBuildInfo () .. MYSLOT_LINE_SEP .. s
457
+ s = " # Myslot (https://myslot.net " .. L [" <- share your profile here" ] .. " )" .. MYSLOT_LINE_SEP .. s
391
458
392
459
local d = base64 .enc (t )
393
460
local LINE_LEN = 60
@@ -524,22 +591,25 @@ function MySlot:FindOrCreateMacro(macroInfo)
524
591
end
525
592
-- }}}
526
593
594
+
595
+
527
596
function MySlot :RecoverData (msg , opt )
528
597
-- {{{ Cache Spells
529
598
-- cache spells
530
599
local spells = {}
531
600
601
+ -- TODO clean up this with 11.0
532
602
if SPELLS_PER_PAGE then
533
603
for i = 1 , GetNumSpellTabs () do
534
- local tab , tabTex , offset , numSpells , isGuild , offSpecID = GetSpellTabInfo (i );
604
+ local tab , tabTex , offset , numSpells , isGuild , offSpecID = GetSpellTabInfo (i )
535
605
offSpecID = (offSpecID ~= 0 )
536
606
if not offSpecID then
537
- offset = offset + 1 ;
538
- local tabEnd = offset + numSpells ;
607
+ offset = offset + 1
608
+ local tabEnd = offset + numSpells
539
609
for j = offset , tabEnd - 1 do
540
610
local spellType , spellId = GetSpellBookItemInfo (j , BOOKTYPE_SPELL )
541
611
if spellType then
542
- local slot = j + (SPELLS_PER_PAGE * (SPELLBOOK_PAGENUMBERS [i ] - 1 ));
612
+ local slot = j + (SPELLS_PER_PAGE * (SPELLBOOK_PAGENUMBERS [i ] - 1 ))
543
613
local spellName = GetSpellInfo (spellId )
544
614
spells [MySlot .SLOT_TYPE [string.lower (spellType )] .. " _" .. spellId ] = { slot , BOOKTYPE_SPELL , " spell" }
545
615
if spellName then -- flyout
@@ -567,6 +637,30 @@ function MySlot:RecoverData(msg, opt)
567
637
end
568
638
end
569
639
end
640
+
641
+ local spellOverride = CreateSpellOverrideMap ()
642
+
643
+ -- 11.0 only
644
+ if C_SpellBook and C_SpellBook .GetNumSpellBookSkillLines then
645
+ local spellmap = {
646
+ -- [Enum.SpellBookItemType.Spell] = "spell",
647
+ [Enum .SpellBookItemType .Flyout ] = " flyout" ,
648
+ }
649
+
650
+ for skillLineIndex = 1 , C_SpellBook .GetNumSpellBookSkillLines () do
651
+ local skillLineInfo = C_SpellBook .GetSpellBookSkillLineInfo (skillLineIndex )
652
+ for i = 1 , skillLineInfo .numSpellBookItems do
653
+ local spellIndex = skillLineInfo .itemIndexOffset + i
654
+ local spellTypeEnum , spellId = C_SpellBook .GetSpellBookItemType (spellIndex , Enum .SpellBookSpellBank .Player );
655
+ if spellId then
656
+ if spellmap [spellTypeEnum ] then
657
+ local spellType = spellmap [spellTypeEnum ]
658
+ spells [MySlot .SLOT_TYPE [string.lower (spellType )] .. " _" .. spellId ] = { spellIndex , Enum .SpellBookSpellBank .Player , " spell" }
659
+ end
660
+ end
661
+ end
662
+ end
663
+ end
570
664
-- }}}
571
665
572
666
@@ -655,12 +749,19 @@ function MySlot:RecoverData(msg, opt)
655
749
return
656
750
end
657
751
658
- if curIndex ~= index or curType ~= slotType or slotType == MYSLOT_MACRO then -- macro always test
752
+ if curIndex ~= index or curType ~= slotType then
659
753
if slotType == MYSLOT_SPELL or slotType == MYSLOT_FLYOUT or slotType == MYSLOT_COMPANION then
660
754
if slotType == MYSLOT_SPELL or slotType == MYSLOT_COMPANION then
661
755
PickupSpell (index )
662
756
end
663
757
758
+ -- try if override
759
+ if not GetCursorInfo () then
760
+ if spellOverride [index ] then
761
+ PickupSpell (spellOverride [index ])
762
+ end
763
+ end
764
+
664
765
if not GetCursorInfo () then
665
766
-- flyout and failover
666
767
@@ -671,26 +772,27 @@ function MySlot:RecoverData(msg, opt)
671
772
if newId then
672
773
if pickType == " spell" then
673
774
PickupSpellBookItem (newId , spellType )
775
+ -- elseif pickType == "spell" then
776
+ -- C_SpellBook.PickupSpellBookItem(newId, spellType);
674
777
elseif pickType == " companions" then
675
778
PickupCompanion (spellType , newId )
676
779
end
677
- else
678
- MySlot :Print (L [" Ignore unlearned skill [id=%s], %s" ]:format (index ,
679
- GetSpellLink (index ) or " " ))
680
780
end
681
781
end
682
- elseif slotType == MYSLOT_ITEM then
683
- PickupItem (index )
684
- -- elseif slotType == MYSLOT_MACRO then
685
- -- local macroid = macro[index]
686
782
687
- -- if not macroid then
688
- -- MySlot:Print(L["Ignore unknown macro [id=%s]"]:format(index))
689
- -- end
783
+ -- this fallback should not happen, only to workaround some old export
784
+ if not GetCursorInfo () then
785
+ local spellName = GetSpellInfo (index )
786
+ if spellName then
787
+ PickupSpell (spellName )
788
+ end
789
+ end
690
790
691
- -- if curType ~= MYSLOT_MACRO or curIndex ~= macroid then
692
- -- PickupMacro(macroid)
693
- -- end
791
+ if not GetCursorInfo () then
792
+ MySlot :Print (L [" Ignore unlearned skill [id=%s], %s" ]:format (index , GetSpellLink (index ) or " " ))
793
+ end
794
+ elseif slotType == MYSLOT_ITEM then
795
+ PickupItem (index )
694
796
elseif slotType == MYSLOT_SUMMONPET and strindex and strindex ~= curIndex then
695
797
C_PetJournal .PickupPet (strindex , false )
696
798
if not GetCursorInfo () then
@@ -765,7 +867,7 @@ function MySlot:RecoverData(msg, opt)
765
867
if not opt .actionOpt .ignorePetActionBar then
766
868
local pettoken = {}
767
869
for i = 1 , NUM_PET_ACTION_SLOTS , 1 do
768
- local name , _ , isToken = GetPetActionInfo (i );
870
+ local name , _ , isToken = GetPetActionInfo (i )
769
871
if isToken then
770
872
pettoken [name ] = i
771
873
end
0 commit comments