madcatzinc@13
|
1 --~ Warcraft Plugin for Cyborg MMO7
|
madcatzinc@0
|
2 --~ Filename: WowObjects.lua
|
madcatzinc@0
|
3 --~ Description: Warcraft in game object models
|
madcatzinc@0
|
4 --~ Copyright (C) 2012 Mad Catz Inc.
|
madcatzinc@0
|
5 --~ Author: Christopher Hooks
|
madcatzinc@0
|
6
|
madcatzinc@0
|
7 --~ This program is free software; you can redistribute it and/or
|
madcatzinc@0
|
8 --~ modify it under the terms of the GNU General Public License
|
madcatzinc@0
|
9 --~ as published by the Free Software Foundation; either version 2
|
madcatzinc@0
|
10 --~ of the License, or (at your option) any later version.
|
madcatzinc@0
|
11
|
madcatzinc@0
|
12 --~ This program is distributed in the hope that it will be useful,
|
madcatzinc@0
|
13 --~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
madcatzinc@0
|
14 --~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
madcatzinc@0
|
15 --~ GNU General Public License for more details.
|
madcatzinc@0
|
16
|
madcatzinc@0
|
17 --~ You should have received a copy of the GNU General Public License
|
madcatzinc@0
|
18 --~ along with this program; if not, write to the Free Software
|
madcatzinc@0
|
19 --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
madcatzinc@0
|
20
|
madcatzinc@25
|
21 ------------------------------------------------------------------------------
|
madcatzinc@0
|
22
|
madcatzinc@25
|
23 local WowObject_methods = {}
|
madcatzinc@25
|
24 local WowObject_mt = {__index=WowObject_methods}
|
madcatzinc@25
|
25
|
madcatzinc@25
|
26 local function WowObject(type, detail, subdetail)
|
madcatzinc@25
|
27 local self = {}
|
madcatzinc@25
|
28
|
madcatzinc@34
|
29 self.type = type
|
madcatzinc@34
|
30 self.detail = detail
|
madcatzinc@34
|
31 self.subdetail = subdetail
|
madcatzinc@25
|
32
|
madcatzinc@25
|
33 setmetatable(self, WowObject_mt)
|
madcatzinc@25
|
34
|
madcatzinc@25
|
35 return self
|
madcatzinc@25
|
36 end
|
madcatzinc@25
|
37
|
madcatzinc@34
|
38 function WowObject_methods:SaveData()
|
madcatzinc@34
|
39 return {
|
madcatzinc@34
|
40 type = self.type,
|
madcatzinc@34
|
41 detail = self.detail,
|
madcatzinc@34
|
42 subdetail = self.subdetail,
|
madcatzinc@34
|
43 }
|
madcatzinc@34
|
44 end
|
madcatzinc@34
|
45
|
madcatzinc@25
|
46 function WowObject_methods:DoAction()
|
madcatzinc@25
|
47 CyborgMMO_DPrint("Nothing To Do")
|
madcatzinc@25
|
48 end
|
madcatzinc@25
|
49
|
madcatzinc@25
|
50 function WowObject_methods:Pickup()
|
madcatzinc@25
|
51 CyborgMMO_DPrint("Pick up Item")
|
madcatzinc@25
|
52 end
|
madcatzinc@25
|
53
|
madcatzinc@25
|
54 function WowObject_methods:SetBinding(key)
|
madcatzinc@25
|
55 end
|
madcatzinc@25
|
56
|
madcatzinc@25
|
57 ------------------------------------------------------------------------------
|
madcatzinc@25
|
58
|
madcatzinc@25
|
59 local WowCallback_methods = setmetatable({}, {__index=WowObject_methods})
|
madcatzinc@25
|
60 local WowCallback_mt = {__index=WowCallback_methods}
|
madcatzinc@25
|
61
|
madcatzinc@25
|
62 local function WowCallback(callbackName)
|
madcatzinc@25
|
63 local self = WowObject("callback", callbackName, "")
|
madcatzinc@25
|
64
|
madcatzinc@34
|
65 self.callbackName = callbackName
|
madcatzinc@47
|
66 self.texture = "Interface\\AddOns\\CyborgMMO7\\Graphics\\"..callbackName.."Unselected"
|
madcatzinc@25
|
67
|
madcatzinc@25
|
68 setmetatable(self, WowCallback_mt)
|
madcatzinc@25
|
69
|
madcatzinc@25
|
70 return self
|
madcatzinc@25
|
71 end
|
madcatzinc@25
|
72
|
madcatzinc@25
|
73 function WowCallback_methods:SetTextures(buttonFrame)
|
madcatzinc@47
|
74 buttonFrame:SetNormalTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.callbackName.."Unselected")
|
madcatzinc@47
|
75 buttonFrame:SetPushedTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.callbackName.."Down")
|
madcatzinc@47
|
76 buttonFrame:SetHighlightTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.callbackName.."Over")
|
madcatzinc@25
|
77 end
|
madcatzinc@25
|
78
|
madcatzinc@25
|
79 function WowCallback_methods:DoAction()
|
madcatzinc@34
|
80 local action = CyborgMMO_CallbackFactory:GetCallback(self.callbackName)
|
madcatzinc@25
|
81 action()
|
madcatzinc@25
|
82 end
|
madcatzinc@25
|
83
|
madcatzinc@25
|
84 function WowCallback_methods:PickupCallback()
|
madcatzinc@25
|
85 local slot = nil
|
madcatzinc@25
|
86 local observers = CyborgMMO_RatPageModel:GetAllObservers()
|
madcatzinc@25
|
87 for i=1,#observers do
|
madcatzinc@25
|
88 if MouseIsOver(observers[i]) then
|
madcatzinc@25
|
89 slot = observers[i]
|
madcatzinc@25
|
90 break
|
madcatzinc@0
|
91 end
|
madcatzinc@25
|
92 end
|
madcatzinc@25
|
93 slot:SetNormalTexture(slot.UnCheckedTexture)
|
madcatzinc@25
|
94 end
|
madcatzinc@0
|
95
|
madcatzinc@25
|
96 function WowCallback_methods:Pickup()
|
madcatzinc@34
|
97 PlaySound("igAbilityIconDrop")
|
madcatzinc@25
|
98 ClearCursor()
|
madcatzinc@25
|
99 self:PickupCallback()
|
madcatzinc@25
|
100 end
|
madcatzinc@0
|
101
|
madcatzinc@25
|
102 function WowCallback_methods:SetBinding(key)
|
madcatzinc@25
|
103 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(function(...) return self:DoAction(...) end)
|
madcatzinc@25
|
104 SetOverrideBindingClick(CyborgMMO_CallbackFactory.Frame, true, key, name, "LeftButton")
|
madcatzinc@25
|
105 end
|
madcatzinc@0
|
106
|
madcatzinc@25
|
107 ------------------------------------------------------------------------------
|
madcatzinc@0
|
108
|
madcatzinc@25
|
109 local WowItem_methods = setmetatable({}, {__index=WowObject_methods})
|
madcatzinc@25
|
110 local WowItem_mt = {__index=WowItem_methods}
|
madcatzinc@0
|
111
|
madcatzinc@34
|
112 local function WowItem(itemID)
|
madcatzinc@39
|
113 local texture = select(10, GetItemInfo(itemID)) -- :FIXME: this may fail too early in the session (like when loading saved data)
|
madcatzinc@39
|
114 if not texture then
|
madcatzinc@39
|
115 return nil
|
madcatzinc@39
|
116 end
|
madcatzinc@39
|
117
|
madcatzinc@34
|
118 local self = WowObject("item", itemID)
|
madcatzinc@0
|
119
|
madcatzinc@34
|
120 self.itemID = itemID
|
madcatzinc@39
|
121 self.texture = texture
|
madcatzinc@0
|
122
|
madcatzinc@25
|
123 setmetatable(self, WowItem_mt)
|
madcatzinc@0
|
124
|
madcatzinc@25
|
125 return self
|
madcatzinc@25
|
126 end
|
madcatzinc@0
|
127
|
madcatzinc@25
|
128 function WowItem_methods:Pickup()
|
madcatzinc@34
|
129 -- PlaySound("igAbilityIconDrop")
|
madcatzinc@25
|
130 ClearCursor()
|
madcatzinc@34
|
131 -- SetCursor(self.texture)
|
madcatzinc@34
|
132 return PickupItem(self.itemID)
|
madcatzinc@25
|
133 end
|
madcatzinc@25
|
134
|
madcatzinc@25
|
135 function WowItem_methods:SetBinding(key)
|
madcatzinc@34
|
136 local name = GetItemInfo(self.itemID)
|
madcatzinc@34
|
137 SetOverrideBindingItem(CyborgMMO_CallbackFactory.Frame, true, key, name)
|
madcatzinc@25
|
138 end
|
madcatzinc@25
|
139
|
madcatzinc@25
|
140 ------------------------------------------------------------------------------
|
madcatzinc@25
|
141
|
madcatzinc@25
|
142 local WowSpell_methods = setmetatable({}, {__index=WowObject_methods})
|
madcatzinc@25
|
143 local WowSpell_mt = {__index=WowSpell_methods}
|
madcatzinc@25
|
144
|
madcatzinc@34
|
145 local function WowSpell(spellID)
|
madcatzinc@39
|
146 local texture = GetSpellTexture(spellID)
|
madcatzinc@39
|
147 if not texture then
|
madcatzinc@39
|
148 return nil
|
madcatzinc@39
|
149 end
|
madcatzinc@39
|
150
|
madcatzinc@34
|
151 local self = WowObject("spell", spellID)
|
madcatzinc@25
|
152
|
madcatzinc@34
|
153 self.spellID = spellID
|
madcatzinc@39
|
154 self.texture = texture
|
madcatzinc@25
|
155
|
madcatzinc@25
|
156 setmetatable(self, WowSpell_mt)
|
madcatzinc@25
|
157
|
madcatzinc@25
|
158 return self
|
madcatzinc@25
|
159 end
|
madcatzinc@25
|
160
|
madcatzinc@25
|
161 function WowSpell_methods:DoAction()
|
madcatzinc@25
|
162 CyborgMMO_DPrint("Cast Spell")
|
madcatzinc@25
|
163 end
|
madcatzinc@25
|
164
|
madcatzinc@25
|
165 function WowSpell_methods:Pickup()
|
madcatzinc@34
|
166 -- PlaySound("igAbilityIconDrop")
|
madcatzinc@25
|
167 ClearCursor()
|
madcatzinc@34
|
168 -- SetCursor(self.texture)
|
madcatzinc@34
|
169 -- return PickupSpellBookItem(self.SpellbookID, self.Spellbook)
|
madcatzinc@34
|
170 return PickupSpell(self.spellID)
|
madcatzinc@25
|
171 end
|
madcatzinc@25
|
172
|
madcatzinc@25
|
173 function WowSpell_methods:SetBinding(key)
|
madcatzinc@34
|
174 -- CyborgMMO_DPrint("Binding to key "..key)
|
madcatzinc@34
|
175 local name = GetSpellInfo(self.spellID)
|
madcatzinc@34
|
176 CyborgMMO_DPrint("binding spell:", self.spellID, name)
|
madcatzinc@34
|
177 SetOverrideBindingSpell(CyborgMMO_CallbackFactory.Frame, true, key, name)
|
madcatzinc@25
|
178 end
|
madcatzinc@25
|
179
|
madcatzinc@25
|
180 ------------------------------------------------------------------------------
|
madcatzinc@25
|
181
|
madcatzinc@25
|
182 local WowMacro_methods = setmetatable({}, {__index=WowObject_methods})
|
madcatzinc@25
|
183 local WowMacro_mt = {__index=WowMacro_methods}
|
madcatzinc@25
|
184
|
madcatzinc@34
|
185 local function WowMacro(name)
|
madcatzinc@39
|
186 local texture = select(2, GetMacroInfo(name))
|
madcatzinc@39
|
187 if not texture then
|
madcatzinc@39
|
188 return nil
|
madcatzinc@39
|
189 end
|
madcatzinc@39
|
190
|
madcatzinc@34
|
191 local self = WowObject("macro", name)
|
madcatzinc@25
|
192
|
madcatzinc@34
|
193 self.name = name
|
madcatzinc@39
|
194 self.texture = texture
|
madcatzinc@25
|
195
|
madcatzinc@25
|
196 setmetatable(self, WowMacro_mt)
|
madcatzinc@25
|
197
|
madcatzinc@25
|
198 return self
|
madcatzinc@25
|
199 end
|
madcatzinc@25
|
200
|
madcatzinc@25
|
201 function WowMacro_methods:DoAction()
|
madcatzinc@25
|
202 CyborgMMO_DPrint("Use Item")
|
madcatzinc@25
|
203 end
|
madcatzinc@25
|
204
|
madcatzinc@25
|
205 function WowMacro_methods:Pickup()
|
madcatzinc@34
|
206 -- PlaySound("igAbilityIconDrop")
|
madcatzinc@25
|
207 ClearCursor()
|
madcatzinc@34
|
208 -- SetCursor(self.texture)
|
madcatzinc@34
|
209 return PickupMacro(self.name)
|
madcatzinc@25
|
210 end
|
madcatzinc@25
|
211
|
madcatzinc@25
|
212 function WowMacro_methods:SetBinding(key)
|
madcatzinc@34
|
213 SetOverrideBindingMacro(CyborgMMO_CallbackFactory.Frame, true, key, self.name)
|
madcatzinc@25
|
214 end
|
madcatzinc@25
|
215
|
madcatzinc@25
|
216 ------------------------------------------------------------------------------
|
madcatzinc@25
|
217
|
madcatzinc@25
|
218 local WowEquipmentSet_methods = setmetatable({}, {__index=WowObject_methods})
|
madcatzinc@25
|
219 local WowEquipmentSet_mt = {__index=WowEquipmentSet_methods}
|
madcatzinc@25
|
220
|
madcatzinc@34
|
221 local function WowEquipmentSet(name)
|
madcatzinc@39
|
222 local texture = GetEquipmentSetInfoByName(name)
|
madcatzinc@39
|
223 if not texture then
|
madcatzinc@39
|
224 return nil
|
madcatzinc@39
|
225 end
|
madcatzinc@39
|
226
|
madcatzinc@34
|
227 local self = WowObject("equipmentset", name)
|
madcatzinc@25
|
228
|
madcatzinc@34
|
229 self.name = name
|
madcatzinc@34
|
230 self.texture = "Interface\\Icons\\"..texture
|
madcatzinc@25
|
231
|
madcatzinc@25
|
232 setmetatable(self, WowEquipmentSet_mt)
|
madcatzinc@25
|
233
|
madcatzinc@25
|
234 return self
|
madcatzinc@25
|
235 end
|
madcatzinc@25
|
236
|
madcatzinc@25
|
237 function WowEquipmentSet_methods:DoAction()
|
madcatzinc@34
|
238 UseEquipmentSet(self.name)
|
madcatzinc@25
|
239 end
|
madcatzinc@25
|
240
|
madcatzinc@25
|
241 function WowEquipmentSet_methods:Pickup()
|
madcatzinc@34
|
242 -- PlaySound("igAbilityIconDrop")
|
madcatzinc@25
|
243 ClearCursor()
|
madcatzinc@34
|
244 -- SetCursor(self.texture)
|
madcatzinc@50
|
245 return PickupEquipmentSetByName(self.name)
|
madcatzinc@25
|
246 end
|
madcatzinc@25
|
247
|
madcatzinc@25
|
248 function WowEquipmentSet_methods:SetBinding(key)
|
madcatzinc@34
|
249 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(function() self:DoAction() end)
|
madcatzinc@34
|
250 SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton")
|
madcatzinc@34
|
251 end
|
madcatzinc@34
|
252
|
madcatzinc@34
|
253 ------------------------------------------------------------------------------
|
madcatzinc@34
|
254
|
madcatzinc@34
|
255 local WowBattlePet_methods = setmetatable({}, {__index=WowObject_methods})
|
madcatzinc@34
|
256 local WowBattlePet_mt = {__index=WowBattlePet_methods}
|
madcatzinc@34
|
257
|
madcatzinc@34
|
258 local function WowBattlePet(petID)
|
madcatzinc@39
|
259 local texture = select(9, C_PetJournal.GetPetInfoByPetID(petID)) -- :FIXME: this may fail too early in the session (like when loading saved data)
|
madcatzinc@39
|
260 if not texture then
|
madcatzinc@39
|
261 return nil
|
madcatzinc@39
|
262 end
|
madcatzinc@39
|
263
|
madcatzinc@34
|
264 local self = WowObject("battlepet", petID)
|
madcatzinc@34
|
265 CyborgMMO_DPrint("creating battle pet binding:", petID)
|
madcatzinc@34
|
266
|
madcatzinc@34
|
267 self.petID = petID
|
madcatzinc@39
|
268 self.texture = texture
|
madcatzinc@34
|
269
|
madcatzinc@34
|
270 setmetatable(self, WowBattlePet_mt)
|
madcatzinc@34
|
271
|
madcatzinc@34
|
272 return self
|
madcatzinc@34
|
273 end
|
madcatzinc@34
|
274
|
madcatzinc@34
|
275 --[[
|
madcatzinc@34
|
276 local function IdentifyPet(petID)
|
madcatzinc@34
|
277 local creatureID = select(11, C_PetJournal.GetPetInfoByPetID(petID))
|
madcatzinc@34
|
278 for index=1,GetNumCompanions('CRITTER') do
|
madcatzinc@34
|
279 local creatureID2,_,spellID = GetCompanionInfo('CRITTER', index)
|
madcatzinc@34
|
280 if creatureID2 == creatureID then
|
madcatzinc@34
|
281 return spellID
|
madcatzinc@34
|
282 end
|
madcatzinc@34
|
283 end
|
madcatzinc@34
|
284 end
|
madcatzinc@34
|
285 --]]
|
madcatzinc@34
|
286
|
madcatzinc@34
|
287 function WowBattlePet_methods:DoAction()
|
madcatzinc@34
|
288 -- PlaySound("igMainMenuOptionCheckBoxOn")
|
madcatzinc@34
|
289 C_PetJournal.SummonPetByGUID(self.petID)
|
madcatzinc@34
|
290 end
|
madcatzinc@34
|
291
|
madcatzinc@34
|
292 function WowBattlePet_methods:Pickup()
|
madcatzinc@34
|
293 -- PlaySound("igAbilityIconDrop")
|
madcatzinc@34
|
294 return C_PetJournal.PickupPet(self.petID)
|
madcatzinc@34
|
295 end
|
madcatzinc@34
|
296
|
madcatzinc@34
|
297 function WowBattlePet_methods:SetBinding(key)
|
madcatzinc@34
|
298 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(function() self:DoAction() end)
|
madcatzinc@25
|
299 SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton")
|
madcatzinc@25
|
300 end
|
madcatzinc@25
|
301
|
madcatzinc@25
|
302 ------------------------------------------------------------------------------
|
madcatzinc@25
|
303
|
jerome@65
|
304 local function GetMountInfoEx(mountID)
|
jerome@65
|
305 -- special case for random mount
|
jerome@65
|
306 if mountID == 0xFFFFFFF then
|
jerome@65
|
307 return 0,"Interface/ICONS/ACHIEVEMENT_GUILDPERK_MOUNTUP"
|
jerome@65
|
308 end
|
jerome@65
|
309
|
jerome@65
|
310 local spellID = CyborgMMO_MountMap[mountID] or CyborgMMO_LocalMountMap[mountID]
|
jerome@65
|
311 if not spellID then return nil,"not in database" end
|
jerome@65
|
312
|
jerome@65
|
313 local mountIndex
|
jerome@65
|
314 for i=1,C_MountJournal.GetNumMounts() do
|
jerome@65
|
315 local _,spell,texture = C_MountJournal.GetMountInfo(i) -- :FIXME: this may fail too early in the session (like when loading saved data)
|
jerome@65
|
316 if spell==spellID then
|
jerome@65
|
317 return i,texture
|
jerome@65
|
318 end
|
jerome@65
|
319 end
|
jerome@65
|
320
|
jerome@65
|
321 return nil,"not in journal"
|
jerome@65
|
322 end
|
jerome@65
|
323
|
jerome@68
|
324 local function FindMountFromSpellID(spellID)
|
jerome@68
|
325 for mount,spell in pairs(CyborgMMO_MountMap) do
|
jerome@68
|
326 if spell==spellID then
|
jerome@68
|
327 return mount
|
jerome@68
|
328 end
|
jerome@68
|
329 end
|
jerome@68
|
330 for mount,spell in pairs(CyborgMMO_MountMap) do
|
jerome@68
|
331 if spell==spellID then
|
jerome@68
|
332 return mount
|
jerome@68
|
333 end
|
jerome@68
|
334 end
|
jerome@68
|
335 for i=1,C_MountJournal.GetNumMounts() do
|
jerome@68
|
336 local _,spell = C_MountJournal.GetMountInfo(i)
|
jerome@68
|
337 if spell==spellID then
|
jerome@68
|
338 local cursor = pack(GetCursorInfo())
|
jerome@68
|
339 C_MountJournal.Pickup(i)
|
jerome@68
|
340 local _,mountID = GetCursorInfo()
|
jerome@68
|
341 ClearCursor()
|
jerome@68
|
342 return mountID
|
jerome@68
|
343 end
|
jerome@68
|
344 end
|
jerome@68
|
345 return nil
|
jerome@68
|
346 end
|
jerome@68
|
347
|
jerome@65
|
348 local WowMount_methods = setmetatable({}, {__index=WowObject_methods})
|
jerome@65
|
349 local WowMount_mt = {__index=WowMount_methods}
|
jerome@65
|
350
|
jerome@65
|
351 local function WowMount(mountID)
|
jerome@65
|
352 local mountIndex,texture = GetMountInfoEx(mountID)
|
jerome@65
|
353 if not mountIndex then
|
jerome@65
|
354 -- the mount might have been removed from the game
|
jerome@65
|
355 return nil
|
jerome@65
|
356 end
|
jerome@65
|
357
|
jerome@65
|
358 local self = WowObject("mount", mountID)
|
jerome@65
|
359 CyborgMMO_DPrint("creating mount binding:", mountID, texture)
|
jerome@65
|
360
|
jerome@65
|
361 self.mountID = mountID
|
jerome@65
|
362 self.texture = texture
|
jerome@65
|
363
|
jerome@65
|
364 setmetatable(self, WowMount_mt)
|
jerome@65
|
365
|
jerome@65
|
366 return self
|
jerome@65
|
367 end
|
jerome@65
|
368
|
jerome@65
|
369 function WowMount_methods:DoAction()
|
jerome@65
|
370 local mountIndex = GetMountInfoEx(self.mountID)
|
jerome@65
|
371 if not mountIndex then return end
|
jerome@65
|
372
|
jerome@65
|
373 C_MountJournal.Summon(mountIndex)
|
jerome@65
|
374 end
|
jerome@65
|
375
|
jerome@65
|
376 function WowMount_methods:Pickup()
|
jerome@65
|
377 local mountIndex = GetMountInfoEx(self.mountID)
|
jerome@65
|
378 if not mountIndex then return end
|
jerome@65
|
379
|
jerome@65
|
380 return C_MountJournal.Pickup(mountIndex)
|
jerome@65
|
381 end
|
jerome@65
|
382
|
jerome@65
|
383 function WowMount_methods:SetBinding(key)
|
jerome@65
|
384 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(function() self:DoAction() end)
|
jerome@65
|
385 SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton")
|
jerome@65
|
386 end
|
jerome@65
|
387
|
jerome@65
|
388 ------------------------------------------------------------------------------
|
jerome@65
|
389
|
madcatzinc@25
|
390 -- this class is used by pre-defined icons in the corner of the Rat page
|
madcatzinc@4
|
391 CyborgMMO_CallbackIcons = {
|
madcatzinc@0
|
392 new = function(self)
|
madcatzinc@13
|
393 self.point,
|
madcatzinc@13
|
394 self.relativeTo,
|
madcatzinc@13
|
395 self.relativePoint,
|
madcatzinc@13
|
396 self.xOfs,
|
madcatzinc@13
|
397 self.yOfs = self:GetPoint()
|
madcatzinc@13
|
398 -- self:SetPoint(self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs)
|
madcatzinc@13
|
399 self.strata = self:GetFrameStrata()
|
madcatzinc@25
|
400 self.wowObject = WowCallback(string.gsub(self:GetName(), self:GetParent():GetName(), "",1))
|
madcatzinc@25
|
401 self.wowObject:SetTextures(self)
|
madcatzinc@0
|
402 self:RegisterForDrag("LeftButton","RightButton")
|
madcatzinc@13
|
403 self:SetResizable(false)
|
madcatzinc@13
|
404
|
madcatzinc@0
|
405 self.OnClick = function()
|
madcatzinc@25
|
406 self.wowObject:DoAction()
|
madcatzinc@0
|
407 end
|
madcatzinc@13
|
408
|
madcatzinc@0
|
409 self.DragStart = function()
|
madcatzinc@13
|
410 self:SetMovable(true)
|
madcatzinc@13
|
411 self:StartMoving()
|
madcatzinc@13
|
412 self.isMoving = true
|
madcatzinc@0
|
413 self:SetFrameStrata("TOOLTIP")
|
madcatzinc@0
|
414 end
|
madcatzinc@13
|
415
|
madcatzinc@0
|
416 self.DragStop = function()
|
madcatzinc@13
|
417 self:SetFrameStrata(self.strata)
|
madcatzinc@13
|
418 self.isMoving = false
|
madcatzinc@13
|
419 self:SetMovable(false)
|
madcatzinc@13
|
420 self:StopMovingOrSizing()
|
madcatzinc@0
|
421
|
madcatzinc@13
|
422 self:ClearAllPoints()
|
madcatzinc@13
|
423 self:SetPoint(self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs)
|
madcatzinc@13
|
424 local x,y = GetCursorPosition()
|
madcatzinc@18
|
425 CyborgMMO_RatPageController:CallbackDropped(self)
|
madcatzinc@0
|
426 end
|
madcatzinc@13
|
427
|
madcatzinc@13
|
428 return self
|
madcatzinc@13
|
429 end,
|
madcatzinc@0
|
430 }
|
madcatzinc@0
|
431
|
madcatzinc@25
|
432 ------------------------------------------------------------------------------
|
madcatzinc@13
|
433
|
madcatzinc@25
|
434 function CyborgMMO_CreateWowObject(type, ...)
|
madcatzinc@39
|
435 local object,unsupported
|
madcatzinc@13
|
436
|
madcatzinc@25
|
437 if type == "item" then
|
madcatzinc@39
|
438 object = WowItem(...)
|
madcatzinc@25
|
439 elseif type == "macro" then
|
madcatzinc@25
|
440 object = WowMacro(...)
|
madcatzinc@25
|
441 elseif type == "spell" then
|
madcatzinc@33
|
442 object = WowSpell(...)
|
madcatzinc@25
|
443 elseif type == "companion" then
|
jerome@68
|
444 -- most likely a legacy mount in an old SavedVariables
|
jerome@68
|
445 local spellID = ...
|
jerome@68
|
446 local mountID = FindMountFromSpellID(spellID)
|
jerome@68
|
447 if mountID then
|
jerome@68
|
448 object = WowMount(mountID)
|
jerome@68
|
449 end
|
madcatzinc@25
|
450 elseif type == "equipmentset" then
|
madcatzinc@34
|
451 object = WowEquipmentSet(...)
|
madcatzinc@34
|
452 elseif type == "battlepet" then
|
madcatzinc@34
|
453 object = WowBattlePet(...)
|
jerome@65
|
454 elseif type == "mount" then
|
jerome@65
|
455 object = WowMount(...)
|
madcatzinc@25
|
456 elseif type == "callback" then
|
madcatzinc@25
|
457 object = WowCallback(...)
|
madcatzinc@25
|
458 else
|
madcatzinc@39
|
459 CyborgMMO_DPrint("unsupported wow object:", type, ...)
|
madcatzinc@39
|
460 unsupported = true
|
madcatzinc@39
|
461 end
|
madcatzinc@39
|
462 if not object and not unsupported then
|
madcatzinc@39
|
463 CyborgMMO_DPrint("creating "..tostring(type).." object failed:", type, ...)
|
madcatzinc@25
|
464 end
|
madcatzinc@13
|
465
|
madcatzinc@25
|
466 return object
|
madcatzinc@25
|
467 end
|
madcatzinc@0
|
468
|
madcatzinc@25
|
469 function CyborgMMO_ClearBinding(key)
|
madcatzinc@25
|
470 SetOverrideBinding(CyborgMMO_CallbackFactory.Frame, true, key, nil)
|
madcatzinc@25
|
471 end
|
madcatzinc@13
|
472
|