Quantcast
WoWInterface - View Single Post - Autocast animated overlay trouble
View Single Post
09-06-14, 12:02 AM   #10
kez717
A Murloc Raider
Join Date: Oct 2008
Posts: 5
Thought I'd post back and give an update. I got your code to work, but it wasn't quite what I was after (close but not quite there since blizzard updated it from the original texture it seems). After hours of more poking around in various addons and bits of code I finally managed to get it to show on a lua only button in a file with just the button (a ways from being in an actual addon, but it's progress). I thought I'd share what I managed to get incase anyone else has similar trouble or would like a clean working script to use as an example.

Its just a simple button (nothing assigned for when clicked or anything), has the on mouseover and on pushed textures working (using a backdrop was the easiest way I found to keep the on push image from over-riding the buttons icon), and most importantly the current autocast animation that is in game. the autocast is set to show when the button is checked and hide when unchecked. the color of the glow can be adjusted by changing the values on the SHINE_ variables, and the size of the "sparkles" can be changed with the multiplier at the bottom of the code.

Code:
local isMyButtonClicked = false
local buttonPet1_icon = {  bgFile = "Interface\\Icons\\ability_hunter_beastcall",    edgeFile = "",  tile = false,  tileSize = 30,}
local buttonPet1 = CreateFrame("CheckButton", "PetButtonCall1", UIParent, "SecureActionButtonTemplate,AutoCastShineTemplate")
local buttonPet1Shine = CreateFrame("CheckButton", "PetButtonCall1Shine", UIParent, "SecureActionButtonTemplate,AutoCastShineTemplate")
buttonPet1:SetSize(30,30)
buttonPet1:SetPoint("CENTER", 0, 0)
buttonPet1:Show()
buttonPet1:SetBackdrop(buttonPet1_icon)
buttonPet1:SetFrameStrata("LOW")
buttonPet1Shine:SetFrameStrata("Medium")

buttonPet1:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square", add)
buttonPet1:SetPushedTexture("Interface\\Buttons\\ui-quickslot-depress", add)

local SHINE_R = .95;
local SHINE_G = .95;
local SHINE_B = .32;

buttonPet1Shine:SetScript("OnClick", function(self, button)
	if isMyButtonClicked==false then
		buttonPet1:SetChecked(true)
		isMyButtonClicked=true
		AutoCastShine_AutoCastStart(self, SHINE_R, SHINE_G, SHINE_B)
	else
		buttonPet1:SetChecked(false)
		isMyButtonClicked=false
		AutoCastShine_AutoCastStop(self)
	end
end)

buttonPet1Shine:RegisterEvent('PLAYER_LOGIN')
buttonPet1Shine:SetScript('OnEvent', function(self)
	for _, sparkle in next, self.sparkles do
		sparkle:SetHeight(sparkle:GetHeight() * 1)
		sparkle:SetWidth(sparkle:GetWidth() * 1)
	end
end)
  Reply With Quote