Mercurial > wow > cyborg-mmo7
diff WowObjects.lua @ 65:8b8b0bade520
Fixed support for mounts using the new MountJournal and mount IDs (no conversion of old profiles at the moment).
author | Jerome Vuarand <jerome.vuarand@gmail.com> |
---|---|
date | Thu, 23 Oct 2014 13:44:59 +0100 |
parents | 7cbd32de1fdd |
children | 840c9f09a707 |
line wrap: on
line diff
--- a/WowObjects.lua Thu Oct 23 12:17:02 2014 +0100 +++ b/WowObjects.lua Thu Oct 23 13:44:59 2014 +0100 @@ -357,6 +357,68 @@ ------------------------------------------------------------------------------ +local function GetMountInfoEx(mountID) + -- special case for random mount + if mountID == 0xFFFFFFF then + return 0,"Interface/ICONS/ACHIEVEMENT_GUILDPERK_MOUNTUP" + end + + local spellID = CyborgMMO_MountMap[mountID] or CyborgMMO_LocalMountMap[mountID] + if not spellID then return nil,"not in database" end + + local mountIndex + for i=1,C_MountJournal.GetNumMounts() do + local _,spell,texture = C_MountJournal.GetMountInfo(i) -- :FIXME: this may fail too early in the session (like when loading saved data) + if spell==spellID then + return i,texture + end + end + + return nil,"not in journal" +end + +local WowMount_methods = setmetatable({}, {__index=WowObject_methods}) +local WowMount_mt = {__index=WowMount_methods} + +local function WowMount(mountID) + local mountIndex,texture = GetMountInfoEx(mountID) + if not mountIndex then + -- the mount might have been removed from the game + return nil + end + + local self = WowObject("mount", mountID) + CyborgMMO_DPrint("creating mount binding:", mountID, texture) + + self.mountID = mountID + self.texture = texture + + setmetatable(self, WowMount_mt) + + return self +end + +function WowMount_methods:DoAction() + local mountIndex = GetMountInfoEx(self.mountID) + if not mountIndex then return end + + C_MountJournal.Summon(mountIndex) +end + +function WowMount_methods:Pickup() + local mountIndex = GetMountInfoEx(self.mountID) + if not mountIndex then return end + + return C_MountJournal.Pickup(mountIndex) +end + +function WowMount_methods:SetBinding(key) + local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(function() self:DoAction() end) + SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") +end + +------------------------------------------------------------------------------ + -- this class is used by pre-defined icons in the corner of the Rat page CyborgMMO_CallbackIcons = { new = function(self) @@ -416,6 +478,8 @@ object = WowEquipmentSet(...) elseif type == "battlepet" then object = WowBattlePet(...) + elseif type == "mount" then + object = WowMount(...) elseif type == "callback" then object = WowCallback(...) else