comparison WowObjects.lua @ 4:d186f8cd5000

Renamed functions to avoid conflicts
author madcatzinc@35b17cf1-18cd-47ff-9ca3-31d6b526ef09
date Mon, 28 May 2012 15:54:52 +0000
parents bf9220814fb5
children 6cb9a2936580
comparison
equal deleted inserted replaced
3:461854a2849c 4:d186f8cd5000
16 16
17 --~ You should have received a copy of the GNU General Public License 17 --~ You should have received a copy of the GNU General Public License
18 --~ along with this program; if not, write to the Free Software 18 --~ along with this program; if not, write to the Free Software
19 --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 20
21 WowObject = { 21 CyborgMMO_WowObject = {
22 new = function(type, detail, subdetail) 22 new = function(type, detail, subdetail)
23 local self = {}; 23 local self = {};
24 self.Texture = nil; 24 self.Texture = nil;
25 self.Name = "NoName"; 25 self.Name = "NoName";
26 self.Type = type; 26 self.Type = type;
46 46
47 return self; 47 return self;
48 end, 48 end,
49 49
50 ClearBinding = function(key) 50 ClearBinding = function(key)
51 local buttonFrame, parentFrame, name = CallbackFactory.Instance().AddCallback(WowObject.DoNothing); 51 local buttonFrame, parentFrame, name = CyborgMMO_CallbackFactory.Instance().AddCallback(CyborgMMO_WowObject.DoNothing);
52 if(1 ~= SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton")) then 52 if(1 ~= SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton")) then
53 msg("Failed to bind companion to button click"); 53 msg("Failed to bind companion to button click");
54 end 54 end
55 end, 55 end,
56 56
57 DoNothing = function() 57 DoNothing = function()
58 end, 58 end,
59 59
60 Load = function(object) 60 Load = function(object)
61 if("item" == type) then 61 if("item" == type) then
62 object = WowItem.Load(Object) 62 object = CyborgMMO_WowItem.Load(Object)
63 elseif("macro" == type) then 63 elseif("macro" == type) then
64 object = WowMacro.Load(object) 64 object = CyborgMMO_WowMacro.Load(object)
65 elseif("spell" == type) then 65 elseif("spell" == type) then
66 object = WowSpell.Load(object) 66 object = CyborgMMO_WowSpell.Load(object)
67 elseif("petaction" == type) then 67 elseif("petaction" == type) then
68 object = WowSpell.Load(object) 68 object = CyborgMMO_WowSpell.Load(object)
69 --elseif("merchant"== type) then 69 --elseif("merchant"== type) then
70 --object = SlotMerchant.new(detail,subdetail) 70 --object = SlotMerchant.new(detail,subdetail)
71 elseif("companion" == type) then 71 elseif("companion" == type) then
72 object = WowCompanion.Load(object) 72 object = CyborgMMO_WowCompanion.Load(object)
73 elseif("equipmentset" == type) then 73 elseif("equipmentset" == type) then
74 object = WowEquipmentSet.Load(object) 74 object = CyborgMMO_WowEquipmentSet.Load(object)
75 else 75 else
76 object = WowObject.new(type,detail, subdetail) 76 object = CyborgMMO_WowObject.new(type,detail, subdetail)
77 end 77 end
78 return object; 78 return object;
79 end, 79 end,
80 80
81 -- Static Methods -- 81 -- Static Methods --
82 Create = function(objectType, detail, subdetail) 82 Create = function(objectType, detail, subdetail)
83 local object; 83 local object;
84 if("item" == objectType) then 84 if("item" == objectType) then
85 object = WowItem.new(detail,subdetail) 85 object = CyborgMMO_WowItem.new(detail,subdetail)
86 elseif("macro" == objectType) then 86 elseif("macro" == objectType) then
87 object = WowMacro.new(detail) 87 object = CyborgMMO_WowMacro.new(detail)
88 elseif("spell" == objectType) then 88 elseif("spell" == objectType) then
89 object = WowSpell.new(objectType, detail,subdetail) 89 object = CyborgMMO_WowSpell.new(objectType, detail,subdetail)
90 elseif("petaction" == objectType) then 90 elseif("petaction" == objectType) then
91 object = WowSpell.new(objectType, detail,subdetail) 91 object = CyborgMMO_WowSpell.new(objectType, detail,subdetail)
92 elseif("merchant"== objectType) then 92 elseif("merchant"== objectType) then
93 object = SlotMerchant.new(detail,subdetail) 93 object = CyborgMMO_SlotMerchant.new(detail,subdetail)
94 elseif("companion" == objectType) then 94 elseif("companion" == objectType) then
95 object = WowCompanion.new(detail,subdetail) 95 object = CyborgMMO_WowCompanion.new(detail,subdetail)
96 elseif("equipmentset" == objectType) then 96 elseif("equipmentset" == objectType) then
97 object = WowEquipmentSet.new(objectType,detail,subdetail) 97 object = CyborgMMO_WowEquipmentSet.new(objectType,detail,subdetail)
98 elseif("callback" == objectType) then 98 elseif("callback" == objectType) then
99 object = WowCallback.new(detail); 99 object = CyborgMMO_WowCallback.new(detail);
100 else 100 else
101 object = WowObject.new(objectType,detail, subdetail) 101 object = CyborgMMO_WowObject.new(objectType,detail, subdetail)
102 end 102 end
103 103
104 return object; 104 return object;
105 end 105 end
106 } 106 }
107 107
108 local CallbackCursor = nil; 108 local CallbackCursor = nil;
109 109
110 CallbackIcons = { 110 CyborgMMO_CallbackIcons = {
111 new = function(self) 111 new = function(self)
112 self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs = self:GetPoint(); 112 self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs = self:GetPoint();
113 --self:SetPoint(self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs); 113 --self:SetPoint(self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs);
114 self.strata = self:GetFrameStrata(); 114 self.strata = self:GetFrameStrata();
115 self.wowObject = WowCallback.new(self:GetName()); 115 self.wowObject = CyborgMMO_WowCallback.new(string.gsub(self:GetName(), self:GetParent():GetName(), "",1))
116 self.wowObject.SetTextures(self); 116 self.wowObject.SetTextures(self);
117 self:RegisterForDrag("LeftButton","RightButton") 117 self:RegisterForDrag("LeftButton","RightButton")
118 self:SetResizable(false); 118 self:SetResizable(false);
119 119
120 self.OnClick = function() 120 self.OnClick = function()
137 self:StopMovingOrSizing(); 137 self:StopMovingOrSizing();
138 138
139 self:ClearAllPoints(); 139 self:ClearAllPoints();
140 self:SetPoint(self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs); 140 self:SetPoint(self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs);
141 local x, y = GetCursorPosition(); 141 local x, y = GetCursorPosition();
142 RatPageController.Instance().CallbackDropped(self) 142 CyborgMMO_RatPageController.Instance().CallbackDropped(self)
143 end 143 end
144 144
145 return self; 145 return self;
146 end 146 end
147 } 147 }
148 148
149 WowCallback = { 149 CyborgMMO_WowCallback = {
150 new = function(callbackName) 150 new = function(callbackName)
151 local self = WowObject.new("callback", callbackName, ""); 151 local self = CyborgMMO_WowObject.new("callback", callbackName, "");
152 self.CallbackName = callbackName; 152 self.CallbackName = callbackName;
153 self.Texture = "Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Unselected.tga" 153 self.Texture = "Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Unselected.tga"
154 154
155 self.SetTextures = function(buttonFrame) 155 self.SetTextures = function(buttonFrame)
156 msg("TextureName = "..self.CallbackName)
156 buttonFrame:SetNormalTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Unselected.tga") 157 buttonFrame:SetNormalTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Unselected.tga")
157 buttonFrame:SetPushedTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Down.tga") 158 buttonFrame:SetPushedTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Down.tga")
158 buttonFrame:SetHighlightTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Over.tga") 159 buttonFrame:SetHighlightTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Over.tga")
159 end 160 end
160 161
161 self.DoAction = function() 162 self.DoAction = function()
162 local action = GetCallback(self.CallbackName) 163 local action = CyborgMMO_CallbackFactory.Instance().GetCallback(self.CallbackName)
163 msg("calling callback:- "..self.CallbackName); 164 msg("calling callback:- "..self.CallbackName);
164 action(); 165 action();
165 166
166 end 167 end
167 168
168 self.PickupCallback = function() 169 self.PickupCallback = function()
169 170
170 local slot = nil; 171 local slot = nil;
171 local observers = RatPageModel.Instance().GetAllObservers(); 172 local observers = CyborgMMO_RatPageModel.Instance().GetAllObservers();
172 for i = 1, (# observers) do 173 for i = 1, (# observers) do
173 if(MouseIsOver(observers[i])) then 174 if(MouseIsOver(observers[i])) then
174 slot = observers[i]; 175 slot = observers[i];
175 break; 176 break;
176 end 177 end
181 182
182 self.ClickHandler = function(self, button, down) 183 self.ClickHandler = function(self, button, down)
183 msg("click handler"); 184 msg("click handler");
184 CallbackCursor:StopMoving(); 185 CallbackCursor:StopMoving();
185 CallbackCursor:Hide(); 186 CallbackCursor:Hide();
186
187 if("LeftButton" == button) then
188 else
189
190 end
191 end 187 end
192 188
193 self.Pickup = function() 189 self.Pickup = function()
194 self.PlaySound() 190 self.PlaySound()
195 ClearCursor(); 191 ClearCursor();
197 193
198 end 194 end
199 195
200 196
201 self.SetBinding = function(key) 197 self.SetBinding = function(key)
202 local buttonFrame, parentFrame, name = CallbackFactory.Instance().AddCallback(self.DoAction); 198 local buttonFrame, parentFrame, name = CyborgMMO_CallbackFactory.Instance().AddCallback(self.DoAction);
203 if(1 ~= SetOverrideBindingClick(CallbackFactory.Instance().Frame, true, key, name, "LeftButton")) then 199 if(1 ~= SetOverrideBindingClick(CyborgMMO_CallbackFactory.Instance().Frame, true, key, name, "LeftButton")) then
204 msg("Failed to Bind modeChange"); 200 msg("Failed to Bind modeChange");
205 end 201 end
206 end 202 end
207 203
208 return self; 204 return self;
209 end 205 end
210 } 206 }
211 207
212 -- WowItem Class -- 208 -- WowItem Class --
213 209
214 WowItem = { 210 CyborgMMO_WowItem = {
215 new = function(number, itemID) 211 new = function(number, itemID)
216 local self = WowObject.new("item", number, itemID); -- base class 212 local self = CyborgMMO_WowObject.new("item", number, itemID); -- base class
217 -- Set all the item info. -- 213 -- Set all the item info. --
218 self.Name, 214 self.Name,
219 self.Link, 215 self.Link,
220 self.Rarity, 216 self.Rarity,
221 self.Level, 217 self.Level,
239 --SetCursor(self.Texture); 235 --SetCursor(self.Texture);
240 return PickupItem(self.Link); 236 return PickupItem(self.Link);
241 end 237 end
242 238
243 self.SetBinding = function(key) 239 self.SetBinding = function(key)
244 SetOverrideBinding(CallbackFactory.Instance().Frame, true, key, "ITEM "..self.Name); 240 SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, key, "ITEM "..self.Name);
245 end 241 end
246 242
247 return self; 243 return self;
248 end, 244 end,
249 } 245 }
250 246
251 -- WowSpell Class -- 247 -- WowSpell Class --
252 248
253 WowSpell = { 249 CyborgMMO_WowSpell = {
254 new = function(type, spellbookID, spellbook) 250 new = function(type, spellbookID, spellbook)
255 local self = WowObject.new(type, spellbookID, spellbook) -- base class 251 local self = CyborgMMO_WowObject.new(type, spellbookID, spellbook) -- base class
256 self.SpellbookID = spellbookID; 252 self.SpellbookID = spellbookID;
257 self.Spellbook = spellbook; 253 self.Spellbook = spellbook;
258 self.Name, self.Rank = GetSpellBookItemName(spellbookID, spellbook); 254 self.Name, self.Rank = GetSpellBookItemName(spellbookID, spellbook);
259 self.Texture = GetSpellBookItemTexture(spellbookID, spellbook); 255 self.Texture = GetSpellBookItemTexture(spellbookID, spellbook);
260 self.Type = type; 256 self.Type = type;
274 end 270 end
275 271
276 self.SetBinding = function(key) 272 self.SetBinding = function(key)
277 msg("Binding to key "..key) 273 msg("Binding to key "..key)
278 self.Key = key 274 self.Key = key
279 SetOverrideBinding(CallbackFactory.Instance().Frame, true, self.Key, self.Type.." "..self.Name); 275 SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, self.Key, self.Type.." "..self.Name);
280 end 276 end
281 277
282 return self; 278 return self;
283 279
284 end, 280 end,
291 end 287 end
292 } 288 }
293 289
294 -- WowMacro Class -- 290 -- WowMacro Class --
295 291
296 WowMacro = { 292 CyborgMMO_WowMacro = {
297 new = function(index) 293 new = function(index)
298 local self = WowObject.new("macro", index, nil); -- base class 294 local self = CyborgMMO_WowObject.new("macro", index, nil); -- base class
299 -- Set all the item info. -- 295 -- Set all the item info. --
300 self.Name, 296 self.Name,
301 self.Texture, 297 self.Texture,
302 self.Body, 298 self.Body,
303 self.isLocal = GetMacroInfo(index); 299 self.isLocal = GetMacroInfo(index);
316 return PickupMacro(self.Index); 312 return PickupMacro(self.Index);
317 end 313 end
318 314
319 self.SetBinding = function(key) 315 self.SetBinding = function(key)
320 self.Key = key; 316 self.Key = key;
321 SetOverrideBinding(CallbackFactory.Instance().Frame, true, key, "MACRO "..self.Index); 317 SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, key, "MACRO "..self.Index);
322 end 318 end
323 319
324 return self; 320 return self;
325 end, 321 end,
326 } 322 }
327 323
328 324
329 -- WowCompanion Class -- 325 -- WowCompanion Class --
330 326
331 WowCompanion = { 327 CyborgMMO_WowCompanion = {
332 new = function(index, SubType) 328 new = function(index, SubType)
333 local self = WowObject.new("companion", index, SubType); -- base class 329 local self = CyborgMMO_WowObject.new("companion", index, SubType); -- base class
334 -- Set all the item info. -- 330 -- Set all the item info. --
335 self.Id, self.Name, self.SpellId, self.Texture, self.isSummoned = GetCompanionInfo(SubType, index); 331 self.Id, self.Name, self.SpellId, self.Texture, self.isSummoned = GetCompanionInfo(SubType, index);
336 self.SubType = SubType; 332 self.SubType = SubType;
337 self.index = index; 333 self.index = index;
338 -- override method -- 334 -- override method --
350 return PickupCompanion(self.SubType, self.index); 346 return PickupCompanion(self.SubType, self.index);
351 end 347 end
352 348
353 self.SetBinding = function(key) 349 self.SetBinding = function(key)
354 self.Key = key 350 self.Key = key
355 local buttonFrame, parentFrame, name = CallbackFactory.Instance().AddCallback(self.DoAction); 351 local buttonFrame, parentFrame, name = CyborgMMO_CallbackFactory.Instance().AddCallback(self.DoAction);
356 if(1 ~= SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton")) then 352 if(1 ~= SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton")) then
357 msg("Failed to bind companion to button click"); 353 msg("Failed to bind companion to button click");
358 end 354 end
359 --SetOverrideBinding(hiddenModeChanger, true, key, "MACRO "..self.Index); 355 --SetOverrideBinding(hiddenModeChanger, true, key, "MACRO "..self.Index);
360 end 356 end
367 return o; 363 return o;
368 end 364 end
369 } 365 }
370 366
371 -- WowMerchant Class -- 367 -- WowMerchant Class --
372 WowMerchant = { 368 CyborgMMO_WowMerchant = {
373 new = function(index) 369 new = function(index)
374 local self = WowObject.new("macro", index, nil); -- base class 370 local self = CyborgMMO_WowObject.new("macro", index, nil); -- base class
375 -- Set all the item info. -- 371 -- Set all the item info. --
376 self.Name, 372 self.Name,
377 self.Texture, 373 self.Texture,
378 self.Price, 374 self.Price,
379 self.Quantity, 375 self.Quantity,
395 return PickupMerchantItem(self.Index); 391 return PickupMerchantItem(self.Index);
396 end 392 end
397 393
398 self.SetBinding = function(key) 394 self.SetBinding = function(key)
399 self.Key = key 395 self.Key = key
400 SetOverrideBinding(CallbackFactory.Instance().Frame, true, key, "MERCHANT "..self.Index); 396 SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, key, "MERCHANT "..self.Index);
401 end 397 end
402 398
403 return self; 399 return self;
404 end, 400 end,
405 } 401 }
406 402
407 -- WowEquipmentSet Class -- 403 -- WowEquipmentSet Class --
408 WowEquipmentSet = { 404 CyborgMMO_WowEquipmentSet = {
409 new = function(objectType, name, index) 405 new = function(objectType, name, index)
410 local self = WowObject.new(objectType, name, index); -- base class 406 local self = CyborgMMO_WowObject.new(objectType, name, index); -- base class
411 -- Set all the item info. -- 407 -- Set all the item info. --
412 texture, lessIndex = GetEquipmentSetInfoByName(name); 408 texture, lessIndex = GetEquipmentSetInfoByName(name);
413 self.Texture = "Interface\\Icons\\"..texture; 409 self.Texture = "Interface\\Icons\\"..texture;
414 self.Name = name 410 self.Name = name
415 self.Index = lessIndex+1; 411 self.Index = lessIndex+1;
427 return PickupEquipmentSetByName(self.Name); 423 return PickupEquipmentSetByName(self.Name);
428 end 424 end
429 425
430 self.SetBinding = function(key) 426 self.SetBinding = function(key)
431 self.Key = key 427 self.Key = key
432 local buttonFrame, parentFrame, name = CallbackFactory.Instance().AddCallback(self.DoAction); 428 local buttonFrame, parentFrame, name = CyborgMMO_CallbackFactory.Instance().AddCallback(self.DoAction);
433 if(1 ~= SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton")) then 429 if(1 ~= SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton")) then
434 msg("Failed to bind companion to button click"); 430 msg("Failed to bind companion to button click");
435 end 431 end
436 end 432 end
437 433