contrebasse@98: local addonName, A = ... contrebasse@98: contrebasse@98: local CAMPFIRE_ID = 818 contrebasse@98: local COOKING_ID = 2550 contrebasse@98: local btn contrebasse@98: local cookingName contrebasse@98: contrebasse@98: -- Create button contrebasse@98: function A.InitialiseCampFireBtn() contrebasse@103: if not GetTradeSkillLine() or InCombatLockdown() then return end contrebasse@103: contrebasse@98: -- create the frame contrebasse@98: btn = CreateFrame("Button", nil, TradeSkillFrame, "SecureActionButtonTemplate") contrebasse@98: btn:SetNormalTexture(select(3,GetSpellInfo(CAMPFIRE_ID))) contrebasse@98: btn:SetSize(24,24) contrebasse@98: btn:SetPoint("BOTTOMRIGHT",TradeSkillFrame,"BOTTOMRIGHT",-10,179) contrebasse@98: contrebasse@98: -- Set the action contrebasse@98: btn:SetAttribute("type", "spell") contrebasse@98: btn:SetAttribute("spell", CAMPFIRE_ID) contrebasse@98: contrebasse@98: -- Set the tooltip contrebasse@98: btn:SetScript("OnEnter",function(self) contrebasse@98: GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT") contrebasse@98: GameTooltip:SetSpellByID(CAMPFIRE_ID) contrebasse@98: GameTooltip:Show() contrebasse@98: end) contrebasse@98: btn:SetScript("OnLeave",function() GameTooltip:Hide(); end) contrebasse@98: contrebasse@98: -- Add cooldown contrebasse@98: btn.cooldown = CreateFrame("Cooldown",nil,btn) contrebasse@98: btn.cooldown:SetAllPoints(btn) contrebasse@98: local CooldownFrame_SetTimer = CooldownFrame_SetTimer contrebasse@98: local GetSpellCooldown = GetSpellCooldown contrebasse@98: btn:SetScript("OnUpdate",function(self) CooldownFrame_SetTimer(self.cooldown,GetSpellCooldown(CAMPFIRE_ID)); end) contrebasse@98: contrebasse@98: -- Show if needed contrebasse@98: A.ManageCampFireBtn() contrebasse@98: end contrebasse@98: contrebasse@98: -- Hide button contrebasse@98: function A.HideCampFireBtn() contrebasse@101: if btn then btn:Hide() end contrebasse@98: end contrebasse@98: contrebasse@98: -- Show button if applicable contrebasse@98: function A.ManageCampFireBtn() contrebasse@98: -- Display only if the tradeskill is Cooking contrebasse@103: if not cookingName then cookingName = GetSpellInfo(COOKING_ID) end contrebasse@103: if GetTradeSkillLine() ~= cookingName then contrebasse@103: if btn then btn:Hide() end contrebasse@98: else contrebasse@103: -- create button if necessary contrebasse@103: if not btn then contrebasse@103: A.InitialiseCampFireBtn() contrebasse@103: end contrebasse@103: -- It may not have been created contrebasse@103: if not btn then return end contrebasse@98: btn:Show() contrebasse@98: end contrebasse@98: end