Mercurial > wow > cyborg-mmo7
comparison WowObjects.lua @ 13:6cb9a2936580
Miscellanous Lua code consistency improvements:
- no semicolon except between statements on same line
- use of implicit cast to bool in if/while conditions, instead of various eq/neq against true, false or nil
- no parenthesis around if/while conditions (C-ism)
- avoid long function calls in if conditions
- removed space in comma-separated expressions lists in multiple assignments
- added spaces between arguments of functions calls
- use tabs for indentation (in Lua files only)
- don't reverse == in if conditions, like "if 42==foo then" (C-ism)
- removed some extra parenthesis in complex expressions (C-ism)
- added spaces around operators in most expressions for ease of reading
- added comma after last element of table initializers
- removed space after # operator
- moved comment prefix of disabled code into tab (to keep disabled code aligned)
| author | madcatzinc@35b17cf1-18cd-47ff-9ca3-31d6b526ef09 | 
|---|---|
| date | Thu, 25 Apr 2013 01:29:45 +0000 | 
| parents | d186f8cd5000 | 
| children | 9f2d838d4f8e | 
   comparison
  equal
  deleted
  inserted
  replaced
| 12:72b92b3e476e | 13:6cb9a2936580 | 
|---|---|
| 1 --~ Warcraft Plugin for Cyborg MMO7 | 1 --~ Warcraft Plugin for Cyborg MMO7 | 
| 2 --~ Filename: WowObjects.lua | 2 --~ Filename: WowObjects.lua | 
| 3 --~ Description: Warcraft in game object models | 3 --~ Description: Warcraft in game object models | 
| 4 --~ Copyright (C) 2012 Mad Catz Inc. | 4 --~ Copyright (C) 2012 Mad Catz Inc. | 
| 5 --~ Author: Christopher Hooks | 5 --~ Author: Christopher Hooks | 
| 6 | 6 | 
| 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 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 | 
| 27 self.Detail = detail; | 27 self.Detail = detail | 
| 28 self.Subdetail = subdetail; | 28 self.Subdetail = subdetail | 
| 29 | |
| 30 | 29 | 
| 31 -- Methods -- | 30 -- Methods -- | 
| 32 self.DoAction = function() | 31 self.DoAction = function() | 
| 33 msg("Nothing To Do"); | 32 msg("Nothing To Do") | 
| 34 end | 33 end | 
| 35 | 34 | 
| 36 self.Pickup = function() | 35 self.Pickup = function() | 
| 37 msg("Pick up Item"); | 36 msg("Pick up Item") | 
| 38 end | 37 end | 
| 39 | 38 | 
| 40 self.SetBinding = function(key) | 39 self.SetBinding = function(key) | 
| 41 end | 40 end | 
| 42 | 41 | 
| 43 self.PlaySound = function() | 42 self.PlaySound = function() | 
| 44 PlaySound("igAbilityIconDrop"); | 43 PlaySound("igAbilityIconDrop") | 
| 45 end | 44 end | 
| 46 | 45 | 
| 47 return self; | 46 return self | 
| 48 end, | 47 end, | 
| 49 | 48 | 
| 50 ClearBinding = function(key) | 49 ClearBinding = function(key) | 
| 51 local buttonFrame, parentFrame, name = CyborgMMO_CallbackFactory.Instance().AddCallback(CyborgMMO_WowObject.DoNothing); | 50 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory.Instance().AddCallback(CyborgMMO_WowObject.DoNothing) | 
| 52 if(1 ~= SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton")) then | 51 local result = SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") | 
| 53 msg("Failed to bind companion to button click"); | 52 if result ~= 1 then | 
| 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 type == "item" then | 
| 62 object = CyborgMMO_WowItem.Load(Object) | 62 object = CyborgMMO_WowItem.Load(Object) | 
| 63 elseif("macro" == type) then | 63 elseif type == "macro" then | 
| 64 object = CyborgMMO_WowMacro.Load(object) | 64 object = CyborgMMO_WowMacro.Load(object) | 
| 65 elseif("spell" == type) then | 65 elseif type == "spell" then | 
| 66 object = CyborgMMO_WowSpell.Load(object) | 66 object = CyborgMMO_WowSpell.Load(object) | 
| 67 elseif("petaction" == type) then | 67 elseif type == "petaction" then | 
| 68 object = CyborgMMO_WowSpell.Load(object) | 68 object = CyborgMMO_WowSpell.Load(object) | 
| 69 --elseif("merchant"== type) then | 69 -- elseif type == "merchant" then | 
| 70 --object = SlotMerchant.new(detail,subdetail) | 70 -- object = SlotMerchant.new(detail, subdetail) | 
| 71 elseif("companion" == type) then | 71 elseif type == "companion" then | 
| 72 object = CyborgMMO_WowCompanion.Load(object) | 72 object = CyborgMMO_WowCompanion.Load(object) | 
| 73 elseif("equipmentset" == type) then | 73 elseif type == "equipmentset" then | 
| 74 object = CyborgMMO_WowEquipmentSet.Load(object) | 74 object = CyborgMMO_WowEquipmentSet.Load(object) | 
| 75 else | 75 else | 
| 76 object = CyborgMMO_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 objectType == "item" then | 
| 85 object = CyborgMMO_WowItem.new(detail,subdetail) | 85 object = CyborgMMO_WowItem.new(detail, subdetail) | 
| 86 elseif("macro" == objectType) then | 86 elseif objectType == "macro" then | 
| 87 object = CyborgMMO_WowMacro.new(detail) | 87 object = CyborgMMO_WowMacro.new(detail) | 
| 88 elseif("spell" == objectType) then | 88 elseif objectType == "spell" then | 
| 89 object = CyborgMMO_WowSpell.new(objectType, detail,subdetail) | 89 object = CyborgMMO_WowSpell.new(objectType, detail, subdetail) | 
| 90 elseif("petaction" == objectType) then | 90 elseif objectType == "petaction" then | 
| 91 object = CyborgMMO_WowSpell.new(objectType, detail,subdetail) | 91 object = CyborgMMO_WowSpell.new(objectType, detail, subdetail) | 
| 92 elseif("merchant"== objectType) then | 92 elseif objectType == "merchant" then | 
| 93 object = CyborgMMO_SlotMerchant.new(detail,subdetail) | 93 object = CyborgMMO_SlotMerchant.new(detail, subdetail) | 
| 94 elseif("companion" == objectType) then | 94 elseif objectType == "companion" then | 
| 95 object = CyborgMMO_WowCompanion.new(detail,subdetail) | 95 object = CyborgMMO_WowCompanion.new(detail, subdetail) | 
| 96 elseif("equipmentset" == objectType) then | 96 elseif objectType == "equipmentset" then | 
| 97 object = CyborgMMO_WowEquipmentSet.new(objectType,detail,subdetail) | 97 object = CyborgMMO_WowEquipmentSet.new(objectType, detail, subdetail) | 
| 98 elseif("callback" == objectType) then | 98 elseif objectType == "callback" then | 
| 99 object = CyborgMMO_WowCallback.new(detail); | 99 object = CyborgMMO_WowCallback.new(detail) | 
| 100 else | 100 else | 
| 101 object = CyborgMMO_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 CyborgMMO_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, | 
| 113 --self:SetPoint(self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs); | 113 self.relativeTo, | 
| 114 self.strata = self:GetFrameStrata(); | 114 self.relativePoint, | 
| 115 self.xOfs, | |
| 116 self.yOfs = self:GetPoint() | |
| 117 -- self:SetPoint(self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs) | |
| 118 self.strata = self:GetFrameStrata() | |
| 115 self.wowObject = CyborgMMO_WowCallback.new(string.gsub(self:GetName(), self:GetParent():GetName(), "",1)) | 119 self.wowObject = CyborgMMO_WowCallback.new(string.gsub(self:GetName(), self:GetParent():GetName(), "",1)) | 
| 116 self.wowObject.SetTextures(self); | 120 self.wowObject.SetTextures(self) | 
| 117 self:RegisterForDrag("LeftButton","RightButton") | 121 self:RegisterForDrag("LeftButton","RightButton") | 
| 118 self:SetResizable(false); | 122 self:SetResizable(false) | 
| 119 | 123 | 
| 120 self.OnClick = function() | 124 self.OnClick = function() | 
| 121 self.wowObject.DoAction(); | 125 self.wowObject.DoAction() | 
| 122 end | 126 end | 
| 123 | 127 | 
| 124 | |
| 125 self.DragStart = function() | 128 self.DragStart = function() | 
| 126 self:SetMovable(true); | 129 self:SetMovable(true) | 
| 127 self:StartMoving(); | 130 self:StartMoving() | 
| 128 self.isMoving = true; | 131 self.isMoving = true | 
| 129 self:SetFrameStrata("TOOLTIP") | 132 self:SetFrameStrata("TOOLTIP") | 
| 130 end | 133 end | 
| 131 | 134 | 
| 132 self.DragStop = function() | 135 self.DragStop = function() | 
| 133 | 136 self:SetFrameStrata(self.strata) | 
| 134 self:SetFrameStrata(self.strata); | 137 self.isMoving = false | 
| 135 self.isMoving = false; | 138 self:SetMovable(false) | 
| 136 self:SetMovable(false); | 139 self:StopMovingOrSizing() | 
| 137 self:StopMovingOrSizing(); | 140 | 
| 138 | 141 self:ClearAllPoints() | 
| 139 self:ClearAllPoints(); | 142 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); | 143 local x,y = GetCursorPosition() | 
| 141 local x, y = GetCursorPosition(); | |
| 142 CyborgMMO_RatPageController.Instance().CallbackDropped(self) | 144 CyborgMMO_RatPageController.Instance().CallbackDropped(self) | 
| 143 end | 145 end | 
| 144 | 146 | 
| 145 return self; | 147 return self | 
| 146 end | 148 end, | 
| 147 } | 149 } | 
| 148 | 150 | 
| 149 CyborgMMO_WowCallback = { | 151 CyborgMMO_WowCallback = { | 
| 150 new = function(callbackName) | 152 new = function(callbackName) | 
| 151 local self = CyborgMMO_WowObject.new("callback", callbackName, ""); | 153 local self = CyborgMMO_WowObject.new("callback", callbackName, "") | 
| 152 self.CallbackName = callbackName; | 154 self.CallbackName = callbackName | 
| 153 self.Texture = "Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Unselected.tga" | 155 self.Texture = "Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Unselected.tga" | 
| 154 | 156 | 
| 155 self.SetTextures = function(buttonFrame) | 157 self.SetTextures = function(buttonFrame) | 
| 156 msg("TextureName = "..self.CallbackName) | 158 msg("TextureName = "..self.CallbackName) | 
| 157 buttonFrame:SetNormalTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Unselected.tga") | 159 buttonFrame:SetNormalTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Unselected.tga") | 
| 158 buttonFrame:SetPushedTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Down.tga") | 160 buttonFrame:SetPushedTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Down.tga") | 
| 159 buttonFrame:SetHighlightTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Over.tga") | 161 buttonFrame:SetHighlightTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Over.tga") | 
| 160 end | 162 end | 
| 161 | 163 | 
| 162 self.DoAction = function() | 164 self.DoAction = function() | 
| 163 local action = CyborgMMO_CallbackFactory.Instance().GetCallback(self.CallbackName) | 165 local action = CyborgMMO_CallbackFactory.Instance().GetCallback(self.CallbackName) | 
| 164 msg("calling callback:- "..self.CallbackName); | 166 msg("calling callback:- "..self.CallbackName) | 
| 165 action(); | 167 action() | 
| 166 | 168 end | 
| 167 end | 169 | 
| 168 | |
| 169 self.PickupCallback = function() | 170 self.PickupCallback = function() | 
| 170 | 171 local slot = nil | 
| 171 local slot = nil; | 172 local observers = CyborgMMO_RatPageModel.Instance().GetAllObservers() | 
| 172 local observers = CyborgMMO_RatPageModel.Instance().GetAllObservers(); | 173 for i=1,#observers do | 
| 173 for i = 1, (# observers) do | 174 if MouseIsOver(observers[i]) then | 
| 174 if(MouseIsOver(observers[i])) then | 175 slot = observers[i] | 
| 175 slot = observers[i]; | 176 break | 
| 176 break; | |
| 177 end | 177 end | 
| 178 end | 178 end | 
| 179 slot:SetNormalTexture(slot.UnCheckedTexture) | 179 slot:SetNormalTexture(slot.UnCheckedTexture) | 
| 180 end | 180 end | 
| 181 | 181 | 
| 182 | |
| 183 self.ClickHandler = function(self, button, down) | 182 self.ClickHandler = function(self, button, down) | 
| 184 msg("click handler"); | 183 msg("click handler") | 
| 185 CallbackCursor:StopMoving(); | 184 CallbackCursor:StopMoving() | 
| 186 CallbackCursor:Hide(); | 185 CallbackCursor:Hide() | 
| 187 end | 186 end | 
| 188 | 187 | 
| 189 self.Pickup = function() | 188 self.Pickup = function() | 
| 190 self.PlaySound() | 189 self.PlaySound() | 
| 191 ClearCursor(); | 190 ClearCursor() | 
| 192 self.PickupCallback(); | 191 self.PickupCallback() | 
| 193 | 192 end | 
| 194 end | 193 | 
| 195 | 194 self.SetBinding = function(key) | 
| 196 | 195 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory.Instance().AddCallback(self.DoAction) | 
| 197 self.SetBinding = function(key) | 196 local result = SetOverrideBindingClick(CyborgMMO_CallbackFactory.Instance().Frame, true, key, name, "LeftButton") | 
| 198 local buttonFrame, parentFrame, name = CyborgMMO_CallbackFactory.Instance().AddCallback(self.DoAction); | 197 if result ~= 1 then | 
| 199 if(1 ~= SetOverrideBindingClick(CyborgMMO_CallbackFactory.Instance().Frame, true, key, name, "LeftButton")) then | 198 msg("Failed to Bind modeChange") | 
| 200 msg("Failed to Bind modeChange"); | |
| 201 end | 199 end | 
| 202 end | 200 end | 
| 203 | 201 | 
| 204 return self; | 202 return self | 
| 205 end | 203 end, | 
| 206 } | 204 } | 
| 207 | 205 | 
| 208 -- WowItem Class -- | 206 -- WowItem Class -- | 
| 209 | |
| 210 CyborgMMO_WowItem = { | 207 CyborgMMO_WowItem = { | 
| 211 new = function(number, itemID) | 208 new = function(number, itemID) | 
| 212 local self = CyborgMMO_WowObject.new("item", number, itemID); -- base class | 209 local self = CyborgMMO_WowObject.new("item", number, itemID) -- base class | 
| 213 -- Set all the item info. -- | 210 -- Set all the item info. -- | 
| 214 self.Name, | 211 self.Name, | 
| 215 self.Link, | 212 self.Link, | 
| 216 self.Rarity, | 213 self.Rarity, | 
| 217 self.Level, | 214 self.Level, | 
| 219 self.Type, | 216 self.Type, | 
| 220 self.SubType, | 217 self.SubType, | 
| 221 self.StackCount, | 218 self.StackCount, | 
| 222 self.EquipLoc, | 219 self.EquipLoc, | 
| 223 self.Texture, | 220 self.Texture, | 
| 224 self.SellPrice = GetItemInfo(itemID); | 221 self.SellPrice = GetItemInfo(itemID) | 
| 225 | 222 | 
| 226 -- override method -- | 223 -- override method -- | 
| 227 self.DoAction = function() | 224 self.DoAction = function() | 
| 228 msg("Use Item"); | 225 msg("Use Item") | 
| 229 end | 226 end | 
| 230 | 227 | 
| 231 -- override method -- | 228 -- override method -- | 
| 232 self.Pickup = function() | 229 self.Pickup = function() | 
| 233 self.PlaySound() | 230 self.PlaySound() | 
| 234 ClearCursor(); | 231 ClearCursor() | 
| 235 --SetCursor(self.Texture); | 232 -- SetCursor(self.Texture) | 
| 236 return PickupItem(self.Link); | 233 return PickupItem(self.Link) | 
| 237 end | 234 end | 
| 238 | 235 | 
| 239 self.SetBinding = function(key) | 236 self.SetBinding = function(key) | 
| 240 SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, key, "ITEM "..self.Name); | 237 SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, key, "ITEM "..self.Name) | 
| 241 end | 238 end | 
| 242 | 239 | 
| 243 return self; | 240 return self | 
| 244 end, | 241 end, | 
| 245 } | 242 } | 
| 246 | 243 | 
| 247 -- WowSpell Class -- | 244 -- WowSpell Class -- | 
| 248 | |
| 249 CyborgMMO_WowSpell = { | 245 CyborgMMO_WowSpell = { | 
| 250 new = function(type, spellbookID, spellbook) | 246 new = function(type, spellbookID, spellbook) | 
| 251 local self = CyborgMMO_WowObject.new(type, spellbookID, spellbook) -- base class | 247 local self = CyborgMMO_WowObject.new(type, spellbookID, spellbook) -- base class | 
| 252 self.SpellbookID = spellbookID; | 248 self.SpellbookID = spellbookID | 
| 253 self.Spellbook = spellbook; | 249 self.Spellbook = spellbook | 
| 254 self.Name, self.Rank = GetSpellBookItemName(spellbookID, spellbook); | 250 self.Name,self.Rank = GetSpellBookItemName(spellbookID, spellbook) | 
| 255 self.Texture = GetSpellBookItemTexture(spellbookID, spellbook); | 251 self.Texture = GetSpellBookItemTexture(spellbookID, spellbook) | 
| 256 self.Type = type; | 252 self.Type = type | 
| 257 | 253 | 
| 258 | 254 | 
| 259 -- override method -- | 255 -- override method -- | 
| 260 self.DoAction = function() | 256 self.DoAction = function() | 
| 261 msg("Cast Spell"); | 257 msg("Cast Spell") | 
| 262 end | 258 end | 
| 263 | 259 | 
| 264 -- override method -- | 260 -- override method -- | 
| 265 self.Pickup = function() | 261 self.Pickup = function() | 
| 266 self.PlaySound() | 262 self.PlaySound() | 
| 267 ClearCursor(); | 263 ClearCursor() | 
| 268 --SetCursor(self.Texture); | 264 -- SetCursor(self.Texture) | 
| 269 return PickupSpellBookItem(self.SpellbookID, self.Spellbook); | 265 return PickupSpellBookItem(self.SpellbookID, self.Spellbook) | 
| 270 end | 266 end | 
| 271 | 267 | 
| 272 self.SetBinding = function(key) | 268 self.SetBinding = function(key) | 
| 273 msg("Binding to key "..key) | 269 msg("Binding to key "..key) | 
| 274 self.Key = key | 270 self.Key = key | 
| 275 SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, self.Key, self.Type.." "..self.Name); | 271 SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, self.Key, self.Type.." "..self.Name) | 
| 276 end | 272 end | 
| 277 | 273 | 
| 278 return self; | 274 return self | 
| 279 | |
| 280 end, | 275 end, | 
| 281 | 276 | 
| 282 Load = function(object) | 277 Load = function(object) | 
| 283 local o = WowSpell.new(object.Type, object.Detail, object.Subdetail); | 278 local o = WowSpell.new(object.Type, object.Detail, object.Subdetail) | 
| 284 o.Name = object.Name; | 279 o.Name = object.Name | 
| 285 o.Texture = object.Texture; | 280 o.Texture = object.Texture | 
| 286 return o; | 281 return o | 
| 287 end | 282 end, | 
| 288 } | 283 } | 
| 289 | 284 | 
| 290 -- WowMacro Class -- | 285 -- WowMacro Class -- | 
| 291 | |
| 292 CyborgMMO_WowMacro = { | 286 CyborgMMO_WowMacro = { | 
| 293 new = function(index) | 287 new = function(index) | 
| 294 local self = CyborgMMO_WowObject.new("macro", index, nil); -- base class | 288 local self = CyborgMMO_WowObject.new("macro", index, nil) -- base class | 
| 295 -- Set all the item info. -- | 289 -- Set all the item info. -- | 
| 296 self.Name, | 290 self.Name, | 
| 297 self.Texture, | 291 self.Texture, | 
| 298 self.Body, | 292 self.Body, | 
| 299 self.isLocal = GetMacroInfo(index); | 293 self.isLocal = GetMacroInfo(index) | 
| 300 self.Index = index; | 294 self.Index = index | 
| 301 | 295 | 
| 302 -- override method -- | 296 -- override method -- | 
| 303 self.DoAction = function() | 297 self.DoAction = function() | 
| 304 msg("Use Item"); | 298 msg("Use Item") | 
| 305 end | 299 end | 
| 306 | 300 | 
| 307 -- override method -- | 301 -- override method -- | 
| 308 self.Pickup = function() | 302 self.Pickup = function() | 
| 309 self.PlaySound() | 303 self.PlaySound() | 
| 310 ClearCursor(); | 304 ClearCursor() | 
| 311 --SetCursor(self.Texture); | 305 -- SetCursor(self.Texture) | 
| 312 return PickupMacro(self.Index); | 306 return PickupMacro(self.Index) | 
| 313 end | 307 end | 
| 314 | 308 | 
| 315 self.SetBinding = function(key) | 309 self.SetBinding = function(key) | 
| 316 self.Key = key; | 310 self.Key = key | 
| 317 SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, key, "MACRO "..self.Index); | 311 SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, key, "MACRO "..self.Index) | 
| 318 end | 312 end | 
| 319 | 313 | 
| 320 return self; | 314 return self | 
| 321 end, | 315 end, | 
| 322 } | 316 } | 
| 323 | |
| 324 | 317 | 
| 325 -- WowCompanion Class -- | 318 -- WowCompanion Class -- | 
| 326 | |
| 327 CyborgMMO_WowCompanion = { | 319 CyborgMMO_WowCompanion = { | 
| 328 new = function(index, SubType) | 320 new = function(index, SubType) | 
| 329 local self = CyborgMMO_WowObject.new("companion", index, SubType); -- base class | 321 local self = CyborgMMO_WowObject.new("companion", index, SubType) -- base class | 
| 330 -- Set all the item info. -- | 322 -- Set all the item info. -- | 
| 331 self.Id, self.Name, self.SpellId, self.Texture, self.isSummoned = GetCompanionInfo(SubType, index); | 323 self.Id, | 
| 332 self.SubType = SubType; | 324 self.Name, | 
| 333 self.index = index; | 325 self.SpellId, | 
| 334 -- override method -- | 326 self.Texture, | 
| 335 self.DoAction = function() | 327 self.isSummoned = GetCompanionInfo(SubType, index) | 
| 336 if((self.SubType == "MOUNT") and IsMounted()) then | 328 self.SubType = SubType | 
| 337 Dismount(); | 329 self.index = index | 
| 330 -- override method -- | |
| 331 self.DoAction = function() | |
| 332 if self.SubType == "MOUNT" and IsMounted() then | |
| 333 Dismount() | |
| 338 else | 334 else | 
| 339 CallCompanion(self.SubType, self.index); | 335 CallCompanion(self.SubType, self.index) | 
| 340 end | 336 end | 
| 341 end | 337 end | 
| 342 | 338 | 
| 343 -- override method -- | 339 -- override method -- | 
| 344 self.Pickup = function() | 340 self.Pickup = function() | 
| 345 self.PlaySound() | 341 self.PlaySound() | 
| 346 return PickupCompanion(self.SubType, self.index); | 342 return PickupCompanion(self.SubType, self.index) | 
| 347 end | 343 end | 
| 348 | 344 | 
| 349 self.SetBinding = function(key) | 345 self.SetBinding = function(key) | 
| 350 self.Key = key | 346 self.Key = key | 
| 351 local buttonFrame, parentFrame, name = CyborgMMO_CallbackFactory.Instance().AddCallback(self.DoAction); | 347 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory.Instance().AddCallback(self.DoAction) | 
| 352 if(1 ~= SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton")) then | 348 local result = SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") | 
| 353 msg("Failed to bind companion to button click"); | 349 if result ~= 1 then | 
| 350 msg("Failed to bind companion to button click") | |
| 354 end | 351 end | 
| 355 --SetOverrideBinding(hiddenModeChanger, true, key, "MACRO "..self.Index); | 352 -- SetOverrideBinding(hiddenModeChanger, true, key, "MACRO "..self.Index) | 
| 356 end | 353 end | 
| 357 | 354 | 
| 358 return self; | 355 return self | 
| 359 end, | 356 end, | 
| 360 | 357 | 
| 361 Load = function(object) | 358 Load = function(object) | 
| 362 local o = WowCompanion.new(object.index, object.SubType); | 359 local o = WowCompanion.new(object.index, object.SubType) | 
| 363 return o; | 360 return o | 
| 364 end | 361 end, | 
| 365 } | 362 } | 
| 366 | 363 | 
| 367 -- WowMerchant Class -- | 364 -- WowMerchant Class -- | 
| 368 CyborgMMO_WowMerchant = { | 365 CyborgMMO_WowMerchant = { | 
| 369 new = function(index) | 366 new = function(index) | 
| 370 local self = CyborgMMO_WowObject.new("macro", index, nil); -- base class | 367 local self = CyborgMMO_WowObject.new("macro", index, nil) -- base class | 
| 371 -- Set all the item info. -- | 368 -- Set all the item info. -- | 
| 372 self.Name, | 369 self.Name, | 
| 373 self.Texture, | 370 self.Texture, | 
| 374 self.Price, | 371 self.Price, | 
| 375 self.Quantity, | 372 self.Quantity, | 
| 376 self.NumAvailable, | 373 self.NumAvailable, | 
| 377 self.IsUsable, | 374 self.IsUsable, | 
| 378 self.ExtendedCost = GetMerchantItemInfo(index); | 375 self.ExtendedCost = GetMerchantItemInfo(index) | 
| 379 self.Index = index; | 376 self.Index = index | 
| 380 | 377 | 
| 381 -- override method -- | 378 -- override method -- | 
| 382 self.DoAction = function() | 379 self.DoAction = function() | 
| 383 msg("Use Item"); | 380 msg("Use Item") | 
| 384 end | 381 end | 
| 385 | 382 | 
| 386 -- override method -- | 383 -- override method -- | 
| 387 self.Pickup = function() | 384 self.Pickup = function() | 
| 388 self.PlaySound() | 385 self.PlaySound() | 
| 389 ClearCursor(); | 386 ClearCursor() | 
| 390 --SetCursor(self.Texture); | 387 -- SetCursor(self.Texture) | 
| 391 return PickupMerchantItem(self.Index); | 388 return PickupMerchantItem(self.Index) | 
| 392 end | 389 end | 
| 393 | 390 | 
| 394 self.SetBinding = function(key) | 391 self.SetBinding = function(key) | 
| 395 self.Key = key | 392 self.Key = key | 
| 396 SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, key, "MERCHANT "..self.Index); | 393 SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, key, "MERCHANT "..self.Index) | 
| 397 end | 394 end | 
| 398 | 395 | 
| 399 return self; | 396 return self | 
| 400 end, | 397 end, | 
| 401 } | 398 } | 
| 402 | 399 | 
| 403 -- WowEquipmentSet Class -- | 400 -- WowEquipmentSet Class -- | 
| 404 CyborgMMO_WowEquipmentSet = { | 401 CyborgMMO_WowEquipmentSet = { | 
| 405 new = function(objectType, name, index) | 402 new = function(objectType, name, index) | 
| 406 local self = CyborgMMO_WowObject.new(objectType, name, index); -- base class | 403 local self = CyborgMMO_WowObject.new(objectType, name, index) -- base class | 
| 407 -- Set all the item info. -- | 404 -- Set all the item info. -- | 
| 408 texture, lessIndex = GetEquipmentSetInfoByName(name); | 405 texture,lessIndex = GetEquipmentSetInfoByName(name) | 
| 409 self.Texture = "Interface\\Icons\\"..texture; | 406 self.Texture = "Interface\\Icons\\"..texture | 
| 410 self.Name = name | 407 self.Name = name | 
| 411 self.Index = lessIndex+1; | 408 self.Index = lessIndex + 1 | 
| 412 | 409 | 
| 413 -- override method -- | 410 -- override method -- | 
| 414 self.DoAction = function() | 411 self.DoAction = function() | 
| 415 UseEquipmentSet(self.Name); | 412 UseEquipmentSet(self.Name) | 
| 416 end | 413 end | 
| 417 | 414 | 
| 418 -- override method -- | 415 -- override method -- | 
| 419 self.Pickup = function() | 416 self.Pickup = function() | 
| 420 self.PlaySound() | 417 self.PlaySound() | 
| 421 ClearCursor(); | 418 ClearCursor() | 
| 422 --SetCursor(self.Texture); | 419 -- SetCursor(self.Texture) | 
| 423 return PickupEquipmentSetByName(self.Name); | 420 return PickupEquipmentSetByName(self.Name) | 
| 424 end | 421 end | 
| 425 | 422 | 
| 426 self.SetBinding = function(key) | 423 self.SetBinding = function(key) | 
| 427 self.Key = key | 424 self.Key = key | 
| 428 local buttonFrame, parentFrame, name = CyborgMMO_CallbackFactory.Instance().AddCallback(self.DoAction); | 425 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory.Instance().AddCallback(self.DoAction); | 
| 429 if(1 ~= SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton")) then | 426 local result = SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") | 
| 430 msg("Failed to bind companion to button click"); | 427 if result ~= 1 then | 
| 428 msg("Failed to bind companion to button click") | |
| 431 end | 429 end | 
| 432 end | 430 end | 
| 433 | 431 | 
| 434 return self; | 432 return self | 
| 435 end, | 433 end, | 
| 436 } | 434 } | 
| 437 | |
| 438 | 435 | 
| 439 -- End Of WowObjects -- | 436 -- End Of WowObjects -- | 
