Mercurial > wow > cyborg-mmo7
view 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 |
line wrap: on
line source
--~ Warcraft Plugin for Cyborg MMO7 --~ Filename: WowObjects.lua --~ Description: Warcraft in game object models --~ Copyright (C) 2012 Mad Catz Inc. --~ Author: Christopher Hooks --~ This program is free software; you can redistribute it and/or --~ modify it under the terms of the GNU General Public License --~ as published by the Free Software Foundation; either version 2 --~ of the License, or (at your option) any later version. --~ This program is distributed in the hope that it will be useful, --~ but WITHOUT ANY WARRANTY; without even the implied warranty of --~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --~ GNU General Public License for more details. --~ You should have received a copy of the GNU General Public License --~ along with this program; if not, write to the Free Software --~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. CyborgMMO_WowObject = { new = function(type, detail, subdetail) local self = {}; self.Texture = nil; self.Name = "NoName"; self.Type = type; self.Detail = detail; self.Subdetail = subdetail; -- Methods -- self.DoAction = function() msg("Nothing To Do"); end self.Pickup = function() msg("Pick up Item"); end self.SetBinding = function(key) end self.PlaySound = function() PlaySound("igAbilityIconDrop"); end return self; end, ClearBinding = function(key) local buttonFrame, parentFrame, name = CyborgMMO_CallbackFactory.Instance().AddCallback(CyborgMMO_WowObject.DoNothing); if(1 ~= SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton")) then msg("Failed to bind companion to button click"); end end, DoNothing = function() end, Load = function(object) if("item" == type) then object = CyborgMMO_WowItem.Load(Object) elseif("macro" == type) then object = CyborgMMO_WowMacro.Load(object) elseif("spell" == type) then object = CyborgMMO_WowSpell.Load(object) elseif("petaction" == type) then object = CyborgMMO_WowSpell.Load(object) --elseif("merchant"== type) then --object = SlotMerchant.new(detail,subdetail) elseif("companion" == type) then object = CyborgMMO_WowCompanion.Load(object) elseif("equipmentset" == type) then object = CyborgMMO_WowEquipmentSet.Load(object) else object = CyborgMMO_WowObject.new(type,detail, subdetail) end return object; end, -- Static Methods -- Create = function(objectType, detail, subdetail) local object; if("item" == objectType) then object = CyborgMMO_WowItem.new(detail,subdetail) elseif("macro" == objectType) then object = CyborgMMO_WowMacro.new(detail) elseif("spell" == objectType) then object = CyborgMMO_WowSpell.new(objectType, detail,subdetail) elseif("petaction" == objectType) then object = CyborgMMO_WowSpell.new(objectType, detail,subdetail) elseif("merchant"== objectType) then object = CyborgMMO_SlotMerchant.new(detail,subdetail) elseif("companion" == objectType) then object = CyborgMMO_WowCompanion.new(detail,subdetail) elseif("equipmentset" == objectType) then object = CyborgMMO_WowEquipmentSet.new(objectType,detail,subdetail) elseif("callback" == objectType) then object = CyborgMMO_WowCallback.new(detail); else object = CyborgMMO_WowObject.new(objectType,detail, subdetail) end return object; end } local CallbackCursor = nil; CyborgMMO_CallbackIcons = { new = function(self) self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs = self:GetPoint(); --self:SetPoint(self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs); self.strata = self:GetFrameStrata(); self.wowObject = CyborgMMO_WowCallback.new(string.gsub(self:GetName(), self:GetParent():GetName(), "",1)) self.wowObject.SetTextures(self); self:RegisterForDrag("LeftButton","RightButton") self:SetResizable(false); self.OnClick = function() self.wowObject.DoAction(); end self.DragStart = function() self:SetMovable(true); self:StartMoving(); self.isMoving = true; self:SetFrameStrata("TOOLTIP") end self.DragStop = function() self:SetFrameStrata(self.strata); self.isMoving = false; self:SetMovable(false); self:StopMovingOrSizing(); self:ClearAllPoints(); self:SetPoint(self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs); local x, y = GetCursorPosition(); CyborgMMO_RatPageController.Instance().CallbackDropped(self) end return self; end } CyborgMMO_WowCallback = { new = function(callbackName) local self = CyborgMMO_WowObject.new("callback", callbackName, ""); self.CallbackName = callbackName; self.Texture = "Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Unselected.tga" self.SetTextures = function(buttonFrame) msg("TextureName = "..self.CallbackName) buttonFrame:SetNormalTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Unselected.tga") buttonFrame:SetPushedTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Down.tga") buttonFrame:SetHighlightTexture("Interface\\AddOns\\CyborgMMO7\\Graphics\\"..self.CallbackName.."Over.tga") end self.DoAction = function() local action = CyborgMMO_CallbackFactory.Instance().GetCallback(self.CallbackName) msg("calling callback:- "..self.CallbackName); action(); end self.PickupCallback = function() local slot = nil; local observers = CyborgMMO_RatPageModel.Instance().GetAllObservers(); for i = 1, (# observers) do if(MouseIsOver(observers[i])) then slot = observers[i]; break; end end slot:SetNormalTexture(slot.UnCheckedTexture) end self.ClickHandler = function(self, button, down) msg("click handler"); CallbackCursor:StopMoving(); CallbackCursor:Hide(); end self.Pickup = function() self.PlaySound() ClearCursor(); self.PickupCallback(); end self.SetBinding = function(key) local buttonFrame, parentFrame, name = CyborgMMO_CallbackFactory.Instance().AddCallback(self.DoAction); if(1 ~= SetOverrideBindingClick(CyborgMMO_CallbackFactory.Instance().Frame, true, key, name, "LeftButton")) then msg("Failed to Bind modeChange"); end end return self; end } -- WowItem Class -- CyborgMMO_WowItem = { new = function(number, itemID) local self = CyborgMMO_WowObject.new("item", number, itemID); -- base class -- Set all the item info. -- self.Name, self.Link, self.Rarity, self.Level, self.MinLevel, self.Type, self.SubType, self.StackCount, self.EquipLoc, self.Texture, self.SellPrice = GetItemInfo(itemID); -- override method -- self.DoAction = function() msg("Use Item"); end -- override method -- self.Pickup = function() self.PlaySound() ClearCursor(); --SetCursor(self.Texture); return PickupItem(self.Link); end self.SetBinding = function(key) SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, key, "ITEM "..self.Name); end return self; end, } -- WowSpell Class -- CyborgMMO_WowSpell = { new = function(type, spellbookID, spellbook) local self = CyborgMMO_WowObject.new(type, spellbookID, spellbook) -- base class self.SpellbookID = spellbookID; self.Spellbook = spellbook; self.Name, self.Rank = GetSpellBookItemName(spellbookID, spellbook); self.Texture = GetSpellBookItemTexture(spellbookID, spellbook); self.Type = type; -- override method -- self.DoAction = function() msg("Cast Spell"); end -- override method -- self.Pickup = function() self.PlaySound() ClearCursor(); --SetCursor(self.Texture); return PickupSpellBookItem(self.SpellbookID, self.Spellbook); end self.SetBinding = function(key) msg("Binding to key "..key) self.Key = key SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, self.Key, self.Type.." "..self.Name); end return self; end, Load = function(object) local o = WowSpell.new(object.Type, object.Detail, object.Subdetail); o.Name = object.Name; o.Texture = object.Texture; return o; end } -- WowMacro Class -- CyborgMMO_WowMacro = { new = function(index) local self = CyborgMMO_WowObject.new("macro", index, nil); -- base class -- Set all the item info. -- self.Name, self.Texture, self.Body, self.isLocal = GetMacroInfo(index); self.Index = index; -- override method -- self.DoAction = function() msg("Use Item"); end -- override method -- self.Pickup = function() self.PlaySound() ClearCursor(); --SetCursor(self.Texture); return PickupMacro(self.Index); end self.SetBinding = function(key) self.Key = key; SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, key, "MACRO "..self.Index); end return self; end, } -- WowCompanion Class -- CyborgMMO_WowCompanion = { new = function(index, SubType) local self = CyborgMMO_WowObject.new("companion", index, SubType); -- base class -- Set all the item info. -- self.Id, self.Name, self.SpellId, self.Texture, self.isSummoned = GetCompanionInfo(SubType, index); self.SubType = SubType; self.index = index; -- override method -- self.DoAction = function() if((self.SubType == "MOUNT") and IsMounted()) then Dismount(); else CallCompanion(self.SubType, self.index); end end -- override method -- self.Pickup = function() self.PlaySound() return PickupCompanion(self.SubType, self.index); end self.SetBinding = function(key) self.Key = key local buttonFrame, parentFrame, name = CyborgMMO_CallbackFactory.Instance().AddCallback(self.DoAction); if(1 ~= SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton")) then msg("Failed to bind companion to button click"); end --SetOverrideBinding(hiddenModeChanger, true, key, "MACRO "..self.Index); end return self; end, Load = function(object) local o = WowCompanion.new(object.index, object.SubType); return o; end } -- WowMerchant Class -- CyborgMMO_WowMerchant = { new = function(index) local self = CyborgMMO_WowObject.new("macro", index, nil); -- base class -- Set all the item info. -- self.Name, self.Texture, self.Price, self.Quantity, self.NumAvailable, self.IsUsable, self.ExtendedCost = GetMerchantItemInfo(index); self.Index = index; -- override method -- self.DoAction = function() msg("Use Item"); end -- override method -- self.Pickup = function() self.PlaySound() ClearCursor(); --SetCursor(self.Texture); return PickupMerchantItem(self.Index); end self.SetBinding = function(key) self.Key = key SetOverrideBinding(CyborgMMO_CallbackFactory.Instance().Frame, true, key, "MERCHANT "..self.Index); end return self; end, } -- WowEquipmentSet Class -- CyborgMMO_WowEquipmentSet = { new = function(objectType, name, index) local self = CyborgMMO_WowObject.new(objectType, name, index); -- base class -- Set all the item info. -- texture, lessIndex = GetEquipmentSetInfoByName(name); self.Texture = "Interface\\Icons\\"..texture; self.Name = name self.Index = lessIndex+1; -- override method -- self.DoAction = function() UseEquipmentSet(self.Name); end -- override method -- self.Pickup = function() self.PlaySound() ClearCursor(); --SetCursor(self.Texture); return PickupEquipmentSetByName(self.Name); end self.SetBinding = function(key) self.Key = key local buttonFrame, parentFrame, name = CyborgMMO_CallbackFactory.Instance().AddCallback(self.DoAction); if(1 ~= SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton")) then msg("Failed to bind companion to button click"); end end return self; end, } -- End Of WowObjects --