Mercurial > wow > cyborg-mmo7
comparison WowObjects.lua @ 25:b7074b47cfc7
Simplified the object system of the WowObject-s.
| author | madcatzinc@35b17cf1-18cd-47ff-9ca3-31d6b526ef09 |
|---|---|
| date | Thu, 25 Apr 2013 01:30:46 +0000 |
| parents | 6906d8ffd580 |
| children | 1c0af1810e06 |
comparison
equal
deleted
inserted
replaced
| 24:6906d8ffd580 | 25:b7074b47cfc7 |
|---|---|
| 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 CyborgMMO_WowObject = { | 21 ------------------------------------------------------------------------------ |
| 22 new = function(type, detail, subdetail) | 22 |
| 23 local self = {} | 23 local WowObject_methods = {} |
| 24 self.Texture = nil | 24 local WowObject_mt = {__index=WowObject_methods} |
| 25 self.Name = "NoName" | 25 |
| 26 self.Type = type | 26 local function WowObject(type, detail, subdetail) |
| 27 self.Detail = detail | 27 local self = {} |
| 28 self.Subdetail = subdetail | 28 |
| 29 | 29 self.Texture = nil |
| 30 -- Methods -- | 30 self.Name = "NoName" |
| 31 self.DoAction = function() | 31 self.Type = type |
| 32 CyborgMMO_DPrint("Nothing To Do") | 32 self.Detail = detail |
| 33 self.Subdetail = subdetail | |
| 34 | |
| 35 setmetatable(self, WowObject_mt) | |
| 36 | |
| 37 return self | |
| 38 end | |
| 39 | |
| 40 function WowObject_methods:DoAction() | |
| 41 CyborgMMO_DPrint("Nothing To Do") | |
| 42 end | |
| 43 | |
| 44 function WowObject_methods:Pickup() | |
| 45 CyborgMMO_DPrint("Pick up Item") | |
| 46 end | |
| 47 | |
| 48 function WowObject_methods:SetBinding(key) | |
| 49 end | |
| 50 | |
| 51 function WowObject_methods:PlaySound() | |
| 52 PlaySound("igAbilityIconDrop") | |
| 53 end | |
| 54 | |
| 55 ------------------------------------------------------------------------------ | |
| 56 | |
| 57 local WowCallback_methods = setmetatable({}, {__index=WowObject_methods}) | |
| 58 local WowCallback_mt = {__index=WowCallback_methods} | |
| 59 | |
| 60 local function WowCallback(callbackName) | |
| 61 local self = WowObject("callback", callbackName, "") | |
| 62 | |
| 63 self.CallbackName = callbackName | |
| 64 self.Texture = "Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Unselected.tga" | |
| 65 | |
| 66 setmetatable(self, WowCallback_mt) | |
| 67 | |
| 68 return self | |
| 69 end | |
| 70 | |
| 71 function WowCallback_methods:SetTextures(buttonFrame) | |
| 72 CyborgMMO_DPrint("TextureName = "..self.CallbackName) | |
| 73 buttonFrame:SetNormalTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Unselected.tga") | |
| 74 buttonFrame:SetPushedTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Down.tga") | |
| 75 buttonFrame:SetHighlightTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Over.tga") | |
| 76 end | |
| 77 | |
| 78 function WowCallback_methods:DoAction() | |
| 79 local action = CyborgMMO_CallbackFactory:GetCallback(self.CallbackName) | |
| 80 CyborgMMO_DPrint("calling callback:- "..self.CallbackName) | |
| 81 action() | |
| 82 end | |
| 83 | |
| 84 function WowCallback_methods:PickupCallback() | |
| 85 local slot = nil | |
| 86 local observers = CyborgMMO_RatPageModel:GetAllObservers() | |
| 87 for i=1,#observers do | |
| 88 if MouseIsOver(observers[i]) then | |
| 89 slot = observers[i] | |
| 90 break | |
| 33 end | 91 end |
| 34 | 92 end |
| 35 self.Pickup = function() | 93 slot:SetNormalTexture(slot.UnCheckedTexture) |
| 36 CyborgMMO_DPrint("Pick up Item") | 94 end |
| 37 end | 95 |
| 38 | 96 function WowCallback_methods:Pickup() |
| 39 self.SetBinding = function(key) | 97 self:PlaySound() |
| 40 end | 98 ClearCursor() |
| 41 | 99 self:PickupCallback() |
| 42 self.PlaySound = function() | 100 end |
| 43 PlaySound("igAbilityIconDrop") | 101 |
| 44 end | 102 function WowCallback_methods:SetBinding(key) |
| 45 | 103 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(function(...) return self:DoAction(...) end) |
| 46 return self | 104 SetOverrideBindingClick(CyborgMMO_CallbackFactory.Frame, true, key, name, "LeftButton") |
| 47 end, | 105 end |
| 48 | 106 |
| 49 ClearBinding = function(key) | 107 ------------------------------------------------------------------------------ |
| 50 SetOverrideBinding(CyborgMMO_CallbackFactory.Frame, true, key, nil) | 108 |
| 51 end, | 109 local WowItem_methods = setmetatable({}, {__index=WowObject_methods}) |
| 52 | 110 local WowItem_mt = {__index=WowItem_methods} |
| 53 -- Static Methods -- | 111 |
| 54 Create = function(objectType, detail, subdetail) | 112 local function WowItem(number, itemID) |
| 55 local object | 113 local self = WowObject("item", number, itemID) |
| 56 if objectType == "item" then | 114 |
| 57 object = CyborgMMO_WowItem.new(detail, subdetail) | 115 self.Name, |
| 58 elseif objectType == "macro" then | 116 self.Link, |
| 59 object = CyborgMMO_WowMacro.new(detail) | 117 self.Rarity, |
| 60 elseif objectType == "spell" then | 118 self.Level, |
| 61 object = CyborgMMO_WowSpell.new(objectType, detail, subdetail) | 119 self.MinLevel, |
| 62 elseif objectType == "petaction" then | 120 self.Type, |
| 63 object = CyborgMMO_WowSpell.new(objectType, detail, subdetail) | 121 self.SubType, |
| 64 elseif objectType == "merchant" then | 122 self.StackCount, |
| 65 object = CyborgMMO_SlotMerchant.new(detail, subdetail) | 123 self.EquipLoc, |
| 66 elseif objectType == "companion" then | 124 self.Texture, |
| 67 object = CyborgMMO_WowCompanion.new(detail, subdetail) | 125 self.SellPrice = GetItemInfo(itemID) |
| 68 elseif objectType == "equipmentset" then | 126 |
| 69 object = CyborgMMO_WowEquipmentSet.new(objectType, detail, subdetail) | 127 setmetatable(self, WowItem_mt) |
| 70 elseif objectType == "callback" then | 128 |
| 71 object = CyborgMMO_WowCallback.new(detail) | 129 return self |
| 72 else | 130 end |
| 73 object = CyborgMMO_WowObject.new(objectType, detail, subdetail) | 131 |
| 74 end | 132 function WowItem_methods:DoAction() |
| 75 | 133 CyborgMMO_DPrint("Use Item") |
| 76 return object | 134 end |
| 77 end, | 135 |
| 78 } | 136 function WowItem_methods:Pickup() |
| 79 | 137 self:PlaySound() |
| 80 local CallbackCursor = nil | 138 ClearCursor() |
| 81 | 139 -- SetCursor(self.Texture) |
| 140 return PickupItem(self.Link) | |
| 141 end | |
| 142 | |
| 143 function WowItem_methods:SetBinding(key) | |
| 144 SetOverrideBinding(CyborgMMO_CallbackFactory.Frame, true, key, "ITEM "..self.Name) | |
| 145 end | |
| 146 | |
| 147 ------------------------------------------------------------------------------ | |
| 148 | |
| 149 local WowSpell_methods = setmetatable({}, {__index=WowObject_methods}) | |
| 150 local WowSpell_mt = {__index=WowSpell_methods} | |
| 151 | |
| 152 local function WowSpell(type, spellbookID, spellbook) | |
| 153 local self = WowObject(type, spellbookID, spellbook) | |
| 154 | |
| 155 self.SpellbookID = spellbookID | |
| 156 self.Spellbook = spellbook | |
| 157 self.Name,self.Rank = GetSpellBookItemName(spellbookID, spellbook) | |
| 158 self.Texture = GetSpellBookItemTexture(spellbookID, spellbook) | |
| 159 self.Type = type | |
| 160 | |
| 161 setmetatable(self, WowSpell_mt) | |
| 162 | |
| 163 return self | |
| 164 end | |
| 165 | |
| 166 function WowSpell_methods:DoAction() | |
| 167 CyborgMMO_DPrint("Cast Spell") | |
| 168 end | |
| 169 | |
| 170 function WowSpell_methods:Pickup() | |
| 171 self:PlaySound() | |
| 172 ClearCursor() | |
| 173 -- SetCursor(self.Texture) | |
| 174 return PickupSpellBookItem(self.SpellbookID, self.Spellbook) | |
| 175 end | |
| 176 | |
| 177 function WowSpell_methods:SetBinding(key) | |
| 178 CyborgMMO_DPrint("Binding to key "..key) | |
| 179 self.Key = key | |
| 180 SetOverrideBinding(CyborgMMO_CallbackFactory.Frame, true, self.Key, self.Type.." "..self.Name) | |
| 181 end | |
| 182 | |
| 183 ------------------------------------------------------------------------------ | |
| 184 | |
| 185 local WowMacro_methods = setmetatable({}, {__index=WowObject_methods}) | |
| 186 local WowMacro_mt = {__index=WowMacro_methods} | |
| 187 | |
| 188 local function WowMacro(index) | |
| 189 local self = WowObject("macro", index, nil) | |
| 190 | |
| 191 self.Name, | |
| 192 self.Texture, | |
| 193 self.Body, | |
| 194 self.isLocal = GetMacroInfo(index) | |
| 195 self.Index = index | |
| 196 | |
| 197 setmetatable(self, WowMacro_mt) | |
| 198 | |
| 199 return self | |
| 200 end | |
| 201 | |
| 202 function WowMacro_methods:DoAction() | |
| 203 CyborgMMO_DPrint("Use Item") | |
| 204 end | |
| 205 | |
| 206 function WowMacro_methods:Pickup() | |
| 207 self:PlaySound() | |
| 208 ClearCursor() | |
| 209 -- SetCursor(self.Texture) | |
| 210 return PickupMacro(self.Index) | |
| 211 end | |
| 212 | |
| 213 function WowMacro_methods:SetBinding(key) | |
| 214 self.Key = key | |
| 215 SetOverrideBinding(CyborgMMO_CallbackFactory.Frame, true, key, "MACRO "..self.Index) | |
| 216 end | |
| 217 | |
| 218 ------------------------------------------------------------------------------ | |
| 219 | |
| 220 local WowCompanion_methods = setmetatable({}, {__index=WowObject_methods}) | |
| 221 local WowCompanion_mt = {__index=WowCompanion_methods} | |
| 222 | |
| 223 local function WowCompanion(index, SubType) | |
| 224 local self = WowObject("companion", index, SubType) | |
| 225 | |
| 226 self.Id, | |
| 227 self.Name, | |
| 228 self.SpellId, | |
| 229 self.Texture, | |
| 230 self.isSummoned = GetCompanionInfo(SubType, index) | |
| 231 self.SubType = SubType | |
| 232 self.index = index | |
| 233 | |
| 234 setmetatable(self, WowCompanion_mt) | |
| 235 | |
| 236 return self | |
| 237 end | |
| 238 | |
| 239 function WowCompanion_methods:DoAction() | |
| 240 if self.SubType == "MOUNT" and IsMounted() then | |
| 241 Dismount() | |
| 242 else | |
| 243 CallCompanion(self.SubType, self.index) | |
| 244 end | |
| 245 end | |
| 246 | |
| 247 function WowCompanion_methods:Pickup() | |
| 248 self:PlaySound() | |
| 249 return PickupCompanion(self.SubType, self.index) | |
| 250 end | |
| 251 | |
| 252 function WowCompanion_methods:SetBinding(key) | |
| 253 self.Key = key | |
| 254 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(function() self:DoAction() end) | |
| 255 SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") | |
| 256 -- SetOverrideBinding(hiddenModeChanger, true, key, "MACRO "..self.Index) | |
| 257 end | |
| 258 | |
| 259 ------------------------------------------------------------------------------ | |
| 260 | |
| 261 local WowMerchant_methods = setmetatable({}, {__index=WowObject_methods}) | |
| 262 local WowMerchant_mt = {__index=WowMerchant_methods} | |
| 263 | |
| 264 local function WowMerchant(index) | |
| 265 local self = WowObject("merchant", index, nil) | |
| 266 | |
| 267 self.Name, | |
| 268 self.Texture, | |
| 269 self.Price, | |
| 270 self.Quantity, | |
| 271 self.NumAvailable, | |
| 272 self.IsUsable, | |
| 273 self.ExtendedCost = GetMerchantItemInfo(index) | |
| 274 self.Index = index | |
| 275 | |
| 276 setmetatable(self, WowMerchant_mt) | |
| 277 | |
| 278 return self | |
| 279 end | |
| 280 | |
| 281 function WowMerchant_methods:DoAction() | |
| 282 CyborgMMO_DPrint("Use Item") | |
| 283 end | |
| 284 | |
| 285 function WowMerchant_methods:Pickup() | |
| 286 self:PlaySound() | |
| 287 ClearCursor() | |
| 288 -- SetCursor(self.Texture) | |
| 289 return PickupMerchantItem(self.Index) | |
| 290 end | |
| 291 | |
| 292 function WowMerchant_methods:SetBinding(key) | |
| 293 self.Key = key | |
| 294 SetOverrideBinding(CyborgMMO_CallbackFactory.Frame, true, key, "MERCHANT "..self.Index) | |
| 295 end | |
| 296 | |
| 297 ------------------------------------------------------------------------------ | |
| 298 | |
| 299 local WowEquipmentSet_methods = setmetatable({}, {__index=WowObject_methods}) | |
| 300 local WowEquipmentSet_mt = {__index=WowEquipmentSet_methods} | |
| 301 | |
| 302 local function WowEquipmentSet(objectType, name, index) | |
| 303 local self = WowObject(objectType, name, index) | |
| 304 | |
| 305 local texture,lessIndex = GetEquipmentSetInfoByName(name) | |
| 306 self.Texture = "Interface\\Icons\\"..texture | |
| 307 self.Name = name | |
| 308 self.Index = lessIndex + 1 | |
| 309 | |
| 310 setmetatable(self, WowEquipmentSet_mt) | |
| 311 | |
| 312 return self | |
| 313 end | |
| 314 | |
| 315 function WowEquipmentSet_methods:DoAction() | |
| 316 UseEquipmentSet(self.Name) | |
| 317 end | |
| 318 | |
| 319 function WowEquipmentSet_methods:Pickup() | |
| 320 self:PlaySound() | |
| 321 ClearCursor() | |
| 322 -- SetCursor(self.Texture) | |
| 323 return PickupEquipmentSetByName(self.Name) | |
| 324 end | |
| 325 | |
| 326 function WowEquipmentSet_methods:SetBinding(key) | |
| 327 self.Key = key | |
| 328 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(function() self:DoAction() end); | |
| 329 SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") | |
| 330 end | |
| 331 | |
| 332 ------------------------------------------------------------------------------ | |
| 333 | |
| 334 -- this class is used by pre-defined icons in the corner of the Rat page | |
| 82 CyborgMMO_CallbackIcons = { | 335 CyborgMMO_CallbackIcons = { |
| 83 new = function(self) | 336 new = function(self) |
| 84 self.point, | 337 self.point, |
| 85 self.relativeTo, | 338 self.relativeTo, |
| 86 self.relativePoint, | 339 self.relativePoint, |
| 87 self.xOfs, | 340 self.xOfs, |
| 88 self.yOfs = self:GetPoint() | 341 self.yOfs = self:GetPoint() |
| 89 -- self:SetPoint(self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs) | 342 -- self:SetPoint(self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs) |
| 90 self.strata = self:GetFrameStrata() | 343 self.strata = self:GetFrameStrata() |
| 91 self.wowObject = CyborgMMO_WowCallback.new(string.gsub(self:GetName(), self:GetParent():GetName(), "",1)) | 344 self.wowObject = WowCallback(string.gsub(self:GetName(), self:GetParent():GetName(), "",1)) |
| 92 self.wowObject.SetTextures(self) | 345 self.wowObject:SetTextures(self) |
| 93 self:RegisterForDrag("LeftButton","RightButton") | 346 self:RegisterForDrag("LeftButton","RightButton") |
| 94 self:SetResizable(false) | 347 self:SetResizable(false) |
| 95 | 348 |
| 96 self.OnClick = function() | 349 self.OnClick = function() |
| 97 self.wowObject.DoAction() | 350 self.wowObject:DoAction() |
| 98 end | 351 end |
| 99 | 352 |
| 100 self.DragStart = function() | 353 self.DragStart = function() |
| 101 self:SetMovable(true) | 354 self:SetMovable(true) |
| 102 self:StartMoving() | 355 self:StartMoving() |
| 118 | 371 |
| 119 return self | 372 return self |
| 120 end, | 373 end, |
| 121 } | 374 } |
| 122 | 375 |
| 123 CyborgMMO_WowCallback = { | 376 ------------------------------------------------------------------------------ |
| 124 new = function(callbackName) | 377 |
| 125 local self = CyborgMMO_WowObject.new("callback", callbackName, "") | 378 function CyborgMMO_CreateWowObject(type, ...) |
| 126 self.CallbackName = callbackName | 379 local object |
| 127 self.Texture = "Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Unselected.tga" | 380 |
| 128 | 381 if type == "item" then |
| 129 self.SetTextures = function(buttonFrame) | 382 object = WowItem(...) |
| 130 CyborgMMO_DPrint("TextureName = "..self.CallbackName) | 383 elseif type == "macro" then |
| 131 buttonFrame:SetNormalTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Unselected.tga") | 384 object = WowMacro(...) |
| 132 buttonFrame:SetPushedTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Down.tga") | 385 elseif type == "spell" then |
| 133 buttonFrame:SetHighlightTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Over.tga") | 386 object = WowSpell(type, ...) |
| 134 end | 387 elseif type == "petaction" then |
| 135 | 388 object = WowSpell(type, ...) |
| 136 self.DoAction = function() | 389 elseif type == "merchant" then |
| 137 local action = CyborgMMO_CallbackFactory:GetCallback(self.CallbackName) | 390 object = WowMerchant(...) |
| 138 CyborgMMO_DPrint("calling callback:- "..self.CallbackName) | 391 elseif type == "companion" then |
| 139 action() | 392 object = WowCompanion(...) |
| 140 end | 393 elseif type == "equipmentset" then |
| 141 | 394 object = WowEquipmentSet(type, ...) |
| 142 self.PickupCallback = function() | 395 elseif type == "callback" then |
| 143 local slot = nil | 396 object = WowCallback(...) |
| 144 local observers = CyborgMMO_RatPageModel:GetAllObservers() | 397 else |
| 145 for i=1,#observers do | 398 object = WowObject(type, ...) |
| 146 if MouseIsOver(observers[i]) then | 399 end |
| 147 slot = observers[i] | 400 |
| 148 break | 401 return object |
| 149 end | 402 end |
| 150 end | 403 |
| 151 slot:SetNormalTexture(slot.UnCheckedTexture) | 404 function CyborgMMO_ClearBinding(key) |
| 152 end | 405 SetOverrideBinding(CyborgMMO_CallbackFactory.Frame, true, key, nil) |
| 153 | 406 end |
| 154 self.ClickHandler = function(self, button, down) | 407 |
| 155 CyborgMMO_DPrint("click handler") | |
| 156 CallbackCursor:StopMoving() | |
| 157 CallbackCursor:Hide() | |
| 158 end | |
| 159 | |
| 160 self.Pickup = function() | |
| 161 self.PlaySound() | |
| 162 ClearCursor() | |
| 163 self.PickupCallback() | |
| 164 end | |
| 165 | |
| 166 self.SetBinding = function(key) | |
| 167 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(self.DoAction) | |
| 168 SetOverrideBindingClick(CyborgMMO_CallbackFactory.Frame, true, key, name, "LeftButton") | |
| 169 end | |
| 170 | |
| 171 return self | |
| 172 end, | |
| 173 } | |
| 174 | |
| 175 -- WowItem Class -- | |
| 176 CyborgMMO_WowItem = { | |
| 177 new = function(number, itemID) | |
| 178 local self = CyborgMMO_WowObject.new("item", number, itemID) -- base class | |
| 179 -- Set all the item info. -- | |
| 180 self.Name, | |
| 181 self.Link, | |
| 182 self.Rarity, | |
| 183 self.Level, | |
| 184 self.MinLevel, | |
| 185 self.Type, | |
| 186 self.SubType, | |
| 187 self.StackCount, | |
| 188 self.EquipLoc, | |
| 189 self.Texture, | |
| 190 self.SellPrice = GetItemInfo(itemID) | |
| 191 | |
| 192 -- override method -- | |
| 193 self.DoAction = function() | |
| 194 CyborgMMO_DPrint("Use Item") | |
| 195 end | |
| 196 | |
| 197 -- override method -- | |
| 198 self.Pickup = function() | |
| 199 self.PlaySound() | |
| 200 ClearCursor() | |
| 201 -- SetCursor(self.Texture) | |
| 202 return PickupItem(self.Link) | |
| 203 end | |
| 204 | |
| 205 self.SetBinding = function(key) | |
| 206 SetOverrideBinding(CyborgMMO_CallbackFactory.Frame, true, key, "ITEM "..self.Name) | |
| 207 end | |
| 208 | |
| 209 return self | |
| 210 end, | |
| 211 } | |
| 212 | |
| 213 -- WowSpell Class -- | |
| 214 CyborgMMO_WowSpell = { | |
| 215 new = function(type, spellbookID, spellbook) | |
| 216 local self = CyborgMMO_WowObject.new(type, spellbookID, spellbook) -- base class | |
| 217 self.SpellbookID = spellbookID | |
| 218 self.Spellbook = spellbook | |
| 219 self.Name,self.Rank = GetSpellBookItemName(spellbookID, spellbook) | |
| 220 self.Texture = GetSpellBookItemTexture(spellbookID, spellbook) | |
| 221 self.Type = type | |
| 222 | |
| 223 | |
| 224 -- override method -- | |
| 225 self.DoAction = function() | |
| 226 CyborgMMO_DPrint("Cast Spell") | |
| 227 end | |
| 228 | |
| 229 -- override method -- | |
| 230 self.Pickup = function() | |
| 231 self.PlaySound() | |
| 232 ClearCursor() | |
| 233 -- SetCursor(self.Texture) | |
| 234 return PickupSpellBookItem(self.SpellbookID, self.Spellbook) | |
| 235 end | |
| 236 | |
| 237 self.SetBinding = function(key) | |
| 238 CyborgMMO_DPrint("Binding to key "..key) | |
| 239 self.Key = key | |
| 240 SetOverrideBinding(CyborgMMO_CallbackFactory.Frame, true, self.Key, self.Type.." "..self.Name) | |
| 241 end | |
| 242 | |
| 243 return self | |
| 244 end, | |
| 245 } | |
| 246 | |
| 247 -- WowMacro Class -- | |
| 248 CyborgMMO_WowMacro = { | |
| 249 new = function(index) | |
| 250 local self = CyborgMMO_WowObject.new("macro", index, nil) -- base class | |
| 251 -- Set all the item info. -- | |
| 252 self.Name, | |
| 253 self.Texture, | |
| 254 self.Body, | |
| 255 self.isLocal = GetMacroInfo(index) | |
| 256 self.Index = index | |
| 257 | |
| 258 -- override method -- | |
| 259 self.DoAction = function() | |
| 260 CyborgMMO_DPrint("Use Item") | |
| 261 end | |
| 262 | |
| 263 -- override method -- | |
| 264 self.Pickup = function() | |
| 265 self.PlaySound() | |
| 266 ClearCursor() | |
| 267 -- SetCursor(self.Texture) | |
| 268 return PickupMacro(self.Index) | |
| 269 end | |
| 270 | |
| 271 self.SetBinding = function(key) | |
| 272 self.Key = key | |
| 273 SetOverrideBinding(CyborgMMO_CallbackFactory.Frame, true, key, "MACRO "..self.Index) | |
| 274 end | |
| 275 | |
| 276 return self | |
| 277 end, | |
| 278 } | |
| 279 | |
| 280 -- WowCompanion Class -- | |
| 281 CyborgMMO_WowCompanion = { | |
| 282 new = function(index, SubType) | |
| 283 local self = CyborgMMO_WowObject.new("companion", index, SubType) -- base class | |
| 284 -- Set all the item info. -- | |
| 285 self.Id, | |
| 286 self.Name, | |
| 287 self.SpellId, | |
| 288 self.Texture, | |
| 289 self.isSummoned = GetCompanionInfo(SubType, index) | |
| 290 self.SubType = SubType | |
| 291 self.index = index | |
| 292 -- override method -- | |
| 293 self.DoAction = function() | |
| 294 if self.SubType == "MOUNT" and IsMounted() then | |
| 295 Dismount() | |
| 296 else | |
| 297 CallCompanion(self.SubType, self.index) | |
| 298 end | |
| 299 end | |
| 300 | |
| 301 -- override method -- | |
| 302 self.Pickup = function() | |
| 303 self.PlaySound() | |
| 304 return PickupCompanion(self.SubType, self.index) | |
| 305 end | |
| 306 | |
| 307 self.SetBinding = function(key) | |
| 308 self.Key = key | |
| 309 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(self.DoAction) | |
| 310 SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") | |
| 311 -- SetOverrideBinding(hiddenModeChanger, true, key, "MACRO "..self.Index) | |
| 312 end | |
| 313 | |
| 314 return self | |
| 315 end, | |
| 316 } | |
| 317 | |
| 318 -- WowMerchant Class -- | |
| 319 CyborgMMO_WowMerchant = { | |
| 320 new = function(index) | |
| 321 local self = CyborgMMO_WowObject.new("macro", index, nil) -- base class | |
| 322 -- Set all the item info. -- | |
| 323 self.Name, | |
| 324 self.Texture, | |
| 325 self.Price, | |
| 326 self.Quantity, | |
| 327 self.NumAvailable, | |
| 328 self.IsUsable, | |
| 329 self.ExtendedCost = GetMerchantItemInfo(index) | |
| 330 self.Index = index | |
| 331 | |
| 332 -- override method -- | |
| 333 self.DoAction = function() | |
| 334 CyborgMMO_DPrint("Use Item") | |
| 335 end | |
| 336 | |
| 337 -- override method -- | |
| 338 self.Pickup = function() | |
| 339 self.PlaySound() | |
| 340 ClearCursor() | |
| 341 -- SetCursor(self.Texture) | |
| 342 return PickupMerchantItem(self.Index) | |
| 343 end | |
| 344 | |
| 345 self.SetBinding = function(key) | |
| 346 self.Key = key | |
| 347 SetOverrideBinding(CyborgMMO_CallbackFactory.Frame, true, key, "MERCHANT "..self.Index) | |
| 348 end | |
| 349 | |
| 350 return self | |
| 351 end, | |
| 352 } | |
| 353 | |
| 354 -- WowEquipmentSet Class -- | |
| 355 CyborgMMO_WowEquipmentSet = { | |
| 356 new = function(objectType, name, index) | |
| 357 local self = CyborgMMO_WowObject.new(objectType, name, index) -- base class | |
| 358 -- Set all the item info. -- | |
| 359 local texture,lessIndex = GetEquipmentSetInfoByName(name) | |
| 360 self.Texture = "Interface\\Icons\\"..texture | |
| 361 self.Name = name | |
| 362 self.Index = lessIndex + 1 | |
| 363 | |
| 364 -- override method -- | |
| 365 self.DoAction = function() | |
| 366 UseEquipmentSet(self.Name) | |
| 367 end | |
| 368 | |
| 369 -- override method -- | |
| 370 self.Pickup = function() | |
| 371 self.PlaySound() | |
| 372 ClearCursor() | |
| 373 -- SetCursor(self.Texture) | |
| 374 return PickupEquipmentSetByName(self.Name) | |
| 375 end | |
| 376 | |
| 377 self.SetBinding = function(key) | |
| 378 self.Key = key | |
| 379 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(self.DoAction); | |
| 380 SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") | |
| 381 end | |
| 382 | |
| 383 return self | |
| 384 end, | |
| 385 } | |
| 386 | |
| 387 -- End Of WowObjects -- |
