comparison KeyButton.lua @ 93:f9df7cd7bfd6 tip

revert pet spell subText collation remove an empty script handler
author Nenue
date Tue, 04 Sep 2018 23:00:21 -0400
parents 5005aecc2dc8
children
comparison
equal deleted inserted replaced
92:c1c9dd6063a8 93:f9df7cd7bfd6
75 icon = [[Interface\\ICONS\\ability_hunter_carve]] 75 icon = [[Interface\\ICONS\\ability_hunter_carve]]
76 } 76 }
77 } 77 }
78 78
79 79
80 -- This is needed to identify a spells that aren't reflected by GetCursorInfo() 80 -- This is needed to identify spells that aren't reflected by GetCursorInfo()
81 kb.OnPickupPetAction = function(slot, ...) 81 kb.OnPickupPetAction = function(slot, ...)
82 local isPickup = GetCursorInfo() 82 local pickupType, texture, slot = GetCursorInfo()
83 print(slot, ...) 83 print('|cFFFF4400PickupPetAction|r', GetCursorInfo())
84 if kb.PetCache.action[slot] then 84
85 if isPickup then 85 CURSOR_SPELLSLOT = slot
86 local key, _, texture = unpack(kb.PetCache.action[slot]) 86 CURSOR_BOOKTYPE = 'pet'
87 local spellName = _G[key] or key 87 CURSOR_TEXTURE = texture
88 if spellName and kb.PetCache.spellslot[spellName] then 88
89 CURSOR_SPELLSLOT = kb.PetCache.spellslot[spellName][1] 89 print('[cursor book]', CURSOR_BOOKTYPE, CURSOR_SPELLSLOT, 'texture:', CURSOR_TEXTURE)
90 CURSOR_BOOKTYPE = BOOKTYPE_PET
91 CURSOR_TEXTURE = _G[texture] or texture
92 end
93 else
94 CURSOR_SPELLSLOT = nil
95 CURSOR_BOOKTYPE = nil
96 CURSOR_TEXTURE = nil
97 end
98 print('|cFFFF4400PickupPetAction|r', isPickup, CURSOR_PETACTION)
99 end
100
101 local name, subtext, texture, isToken = GetPetActionInfo(slot)
102 if name then
103 kb.PetCache.action[slot] = {name, subtext, texture, isToken}
104 end
105
106
107 print('current cursor info', CURSOR_SPELLSLOT, CURSOR_BOOKTYPE, CURSOR_TEXTURE)
108 90
109 end 91 end
110 92
111 kb.OnPickupSpellBookItem = function(slot, bookType) 93 kb.OnPickupSpellBookItem = function(slot, bookType)
112 print('|cFFFF4400PickupSpellBookItem('.. tostring(slot).. ', '..tostring(bookType)..')') 94 print('|cFFFF4400PickupSpellBookItem('.. tostring(slot).. ', '..tostring(bookType)..')')
113 CURSOR_SPELLSLOT = slot 95 CURSOR_SPELLSLOT = slot
114 CURSOR_BOOKTYPE = bookType 96 CURSOR_BOOKTYPE = bookType
115 CURSOR_TEXTURE = GetSpellBookItemTexture(slot, bookType) 97 CURSOR_TEXTURE = GetSpellBookItemTexture(slot, bookType)
116 print('current cursor info', CURSOR_SPELLSLOT, CURSOR_BOOKTYPE, CURSOR_TEXTURE) 98 print('[cursor book]', CURSOR_BOOKTYPE, CURSOR_SPELLSLOT, 'texture:', CURSOR_TEXTURE)
117 end 99 end
118 100
119 kb.CreateHooks = function() 101 kb.CreateHooks = function()
120 hooksecurefunc("PickupSpellBookItem", kb.OnPickupSpellBookItem) 102 hooksecurefunc("PickupSpellBookItem", kb.OnPickupSpellBookItem)
121 hooksecurefunc("PickupPetAction", kb.OnPickupPetAction) 103 hooksecurefunc("PickupPetAction", kb.OnPickupPetAction)
151 self:GetParent():DeactivateSlot(self) 133 self:GetParent():DeactivateSlot(self)
152 SkeletonKey:Update() 134 SkeletonKey:Update()
153 end 135 end
154 end 136 end
155 137
156 function skb:OnUpdate()
157 end
158 function skb:OnClick(click) 138 function skb:OnClick(click)
159 print(self:GetName(), 'OnMouseDown', click) 139 print(self:GetName(), 'OnMouseDown', click)
160 local cursorType = GetCursorInfo() 140 local cursorType = GetCursorInfo()
161 if click == 'LeftButton' then 141 if click == 'LeftButton' then
162 if cursorType then 142 if cursorType then
185 function skb:OnReceiveDrag(...) 165 function skb:OnReceiveDrag(...)
186 self:DropToSlot() 166 self:DropToSlot()
187 end 167 end
188 168
189 function skb:DropToSlot () 169 function skb:DropToSlot ()
190 print(self:GetName(),'|cFF0088FFreceived|r')
191 local actionType, actionID, subType, subData = GetCursorInfo() 170 local actionType, actionID, subType, subData = GetCursorInfo()
192 print('GetCursorInfo', GetCursorInfo()) 171 print(self:GetName(),'|cFF0088FFDropToSlot|r', actionType, actionID, subType, subData)
193 if actionType then 172 if actionType then
173 print('##', actionType)
194 174
195 if actionType == 'flyout' then 175 if actionType == 'flyout' then
176 print('## flyout button, abort')
196 ClearCursor() 177 ClearCursor()
197 ResetCursor() 178 ResetCursor()
198 return 179 return
199 end 180 end
200 181
201 182
202 local name, icon, _, macroName, macroText 183 local name, icon, _, macroName, macroText
203 local pickupID, pickupBook 184 local pickupID, pickupBook
204 185
205 if actionType == 'spell' then 186 if actionType == 'spell' then
206 local realName = GetSpellInfo(subData) 187 local realName = GetSpellInfo(subData)
207 name, _, icon, _, _, _, actionID = GetSpellInfo(subData) 188 name, _, icon, _, _, _, actionID = GetSpellInfo(subData)
208 189
209 if TALENT_SPELLS[actionID] then 190 if TALENT_SPELLS[actionID] then
210 name = TALENT_SPELLS[actionID].actionName 191 name = TALENT_SPELLS[actionID].actionName
211 actionID = TALENT_SPELLS[actionID].actionID 192 actionID = TALENT_SPELLS[actionID].actionID
212 icon = TALENT_SPELLS[actionID].icon 193 icon = TALENT_SPELLS[actionID].icon
213 elseif actionType == 'macro' then 194 end
214 name, icon, macroText = GetMacroInfo(actionID) 195
215 macroName = name 196 elseif actionType == 'macro' then
216 elseif actionType == 'petaction' then 197 name, icon, macroText = GetMacroInfo(actionID)
217 if CURSOR_SPELLSLOT and CURSOR_BOOKTYPE then 198 macroName = name
218 199 elseif actionType == 'petaction' then
219 local spellType, spellID = GetSpellBookItemInfo(CURSOR_SPELLSLOT, CURSOR_BOOKTYPE) 200
220 local spellName, spellText = GetSpellBookItemName(CURSOR_SPELLSLOT, CURSOR_BOOKTYPE) 201
221 if spellType == 'PETACTION' then 202
222 name = spellName 203 --local spellType, spellID = GetSpellBookItemInfo(actionID, BOOKTYPE_PET)
223 actionID = spellText 204 local spellName, spellText = GetSpellBookItemName(actionID, BOOKTYPE_PET)
224 icon = CURSOR_TEXTURE 205
225 else 206 if subType then
226 name, _, icon = GetSpellInfo(spellID) 207 actionID = subType
227 actionID = spellID 208 end
228 end 209
229 210
230 pickupID = CURSOR_SPELLSLOT 211
231 pickupBook = CURSOR_BOOKTYPE 212 print('##PET', actionID, '=>', spellName, spellText)
232 else 213 pickupID = actionID
233 214 name = GetSpellBookItemName(actionID, BOOKTYPE_PET)
234 215 icon = GetSpellBookItemTexture(actionID, BOOKTYPE_PET)
235 end 216 actionID = name
236 217 pickupBook = BOOKTYPE_PET
237 elseif actionType == 'mount' then 218
238 if subType == 0 then 219 elseif actionType == 'mount' then
239 name, _, icon = GetSpellInfo(SUMMON_RANDOM_FAVORITE_MOUNT_SPELL) 220 if subType == 0 then
240 actionID = 0 221 name, _, icon = GetSpellInfo(SUMMON_RANDOM_FAVORITE_MOUNT_SPELL)
241 else 222 actionID = 0
242 name, _, icon = GetMountInfoByID(actionID) 223 else
243 end 224 name, _, icon = GetMountInfoByID(actionID)
244 elseif actionType == 'item' then 225 end
245 name = GetItemInfo(actionID) 226 elseif actionType == 'item' then
246 icon = GetItemIcon(actionID) 227 name = GetItemInfo(actionID)
247 elseif actionType == 'battlepet' then 228 icon = GetItemIcon(actionID)
248 229 elseif actionType == 'battlepet' then
249 local speciesID, customName, level, xp, maxXp, displayID, isFavorite, petName, petIcon, petType, creatureID = GetPetInfoByPetID(actionID) 230
250 name = customName or petName 231 local speciesID, customName, level, xp, maxXp, displayID, isFavorite, petName, petIcon, petType, creatureID = GetPetInfoByPetID(actionID)
251 icon = petIcon 232 name = customName or petName
252 233 icon = petIcon
253 end 234
254 local _, macroBody, command = kb.RegisterAction(actionType, actionID, name) 235 end
255 local slotInfo = { 236 local _, macroBody, command = kb.RegisterAction(actionType, actionID, name)
256 command = command, 237 local slotInfo = {
257 actionName = name, 238 command = command,
258 iconPath = icon, 239 actionName = name,
259 actionType = actionType, 240 iconPath = icon,
260 actionID = actionID, 241 actionType = actionType,
261 macroName = macroName, 242 actionID = actionID,
262 macroText = macroText or macroBody, 243 macroName = macroName,
263 spellbookSlot = pickupID, 244 macroText = macroText or macroBody,
264 spellbookType = pickupBook, 245 spellbookSlot = pickupID,
265 assignedKeys = {GetBindingKey(command)} 246 spellbookType = pickupBook,
266 } 247 assignedKeys = {GetBindingKey(command)}
267 248 }
268 local isAssigned, isBound, assignedBy, boundBy = kb.IsCommandBound(self, command) 249
250 local isAssigned, isBound, assignedBy, boundBy = kb.IsCommandBound(self, command)
269 if isAssigned then 251 if isAssigned then
270 local popup = StaticPopupDialogs["SKELETONKEY_CONFIRM_ASSIGN_SLOT"] 252 local popup = StaticPopupDialogs["SKELETONKEY_CONFIRM_ASSIGN_SLOT"]
271 popup.slot = self 253 popup.slot = self
272 popup.text = "Currently assigned in |cFFFFFF00"..tostring(kb.configHeaders[assignedBy]).."|r. Are you sure?" 254 popup.text = "Currently assigned in |cFFFFFF00"..tostring(kb.configHeaders[assignedBy]).."|r. Are you sure?"
273 popup.oldProfile = assignedBy 255 popup.oldProfile = assignedBy
282 self.active = nil 264 self.active = nil
283 ClearCursor() 265 ClearCursor()
284 ResetCursor() 266 ResetCursor()
285 end 267 end
286 end 268 end
287 end
288 end 269 end
289 270
290 271
291 272
292 do 273 do