Quantcast

Rewrite and replace animations with a texture

p3lim [12-12-10 - 23:03]
Rewrite and replace animations with a texture
Filename
Molinari.lua
diff --git a/Molinari.lua b/Molinari.lua
index 7ee06d5..147b815 100644
--- a/Molinari.lua
+++ b/Molinari.lua
@@ -1,71 +1,65 @@
-local addonName, spells = ...
-local button = CreateFrame('Button', addonName, UIParent, 'SecureActionButtonTemplate, AutoCastShineTemplate')
-button:SetScript('OnEvent', function(self, event, ...) self[event](self, event, ...) end)
+
+local button = CreateFrame('Button', 'Molinari', UIParent, 'SecureActionButtonTemplate')
+button:SetScript('OnEvent', function(self, event, ...) self[event](self, ...) end)
 button:RegisterEvent('PLAYER_LOGIN')

-local function ScanTooltip()
-	for index = 1, GameTooltip:NumLines() do
-		local info = spells[_G['GameTooltipTextLeft'..index]:GetText()]
+local function ScanTooltip(self, spells)
+	for index = 1, self:NumLines() do
+		local info = spells[_G['GameTooltipTextLeft' .. index]:GetText()]
 		if(info) then
 			return unpack(info)
 		end
 	end
 end

-local function OnLeave(self)
-	if(InCombatLockdown()) then
-		self:RegisterEvent('PLAYER_REGEN_ENABLED')
-	else
-		AutoCastShine_AutoCastStop(self)
-		self:ClearAllPoints()
-		self:Hide()
-	end
-end
-
-local function OnTooltip(self)
-	if(self:GetItem() and not InCombatLockdown() and IsAltKeyDown()) then
-		local spell, r, g, b = ScanTooltip()
-
-		if(spell) then
-			local bag, slot = GetMouseFocus():GetParent(), GetMouseFocus()
-			button:SetAttribute('macrotext', string.format('/cast %s\n/use %s %s', spell, bag:GetID(), slot:GetID()))
-			AutoCastShine_AutoCastStart(button, r, g, b)
-			button:SetAllPoints(slot)
-			button:Show()
-		end
-	end
-end
-
 function button:PLAYER_LOGIN()
-	if(not IsSpellKnown(51005) and not IsSpellKnown(31252)) then return end
-
+	local spells = {}
 	if(IsSpellKnown(51005)) then
 		spells[ITEM_MILLABLE] = {GetSpellInfo(51005), 1/2, 1, 1/2}
 	end
+
 	if(IsSpellKnown(31252)) then
-		spells[ITEM_PROSPECTABLE] = {GetSpellInfo(31252), 1, 1/2, 1/2}
+		spells[ITEM_PROSPECTABLE] = {GetSpellInfo(31252), 1, 1/3, 1/3}
 	end

-	GameTooltip:HookScript('OnTooltipSetItem', OnTooltip)
+	GameTooltip:HookScript('OnTooltipSetItem', function(self)
+		local item, link = self:GetItem()
+		if(item and not InCombatLockdown() and IsAltKeyDown()) then
+			local spell, r, g, b = ScanTooltip(self, spells)
+
+			local bag, slot = GetMouseFocus():GetParent(), GetMouseFocus()
+			if(spell) then
+				button:SetAttribute('macrotext', string.format('/cast %s\n/use %s %s', spell, slot:GetParent():GetID(), slot:GetID()))
+				button:GetNormalTexture():SetVertexColor(r, g, b)
+				button:SetAllPoints(slot)
+				button:Show()
+			end
+		end
+	end)
+
 	self:SetFrameStrata('DIALOG')
 	self:SetAttribute('alt-type1', 'macro')
-	self:SetScript('OnLeave', OnLeave)
+	self:SetNormalTexture([=[Interface\PaperDollInfoFrame\UI-GearManager-ItemButton-Highlight]=])
+	self:GetNormalTexture():SetTexCoord(0.11, 0.66, .11, 0.66)
+	self:SetScript('OnLeave', self.MODIFIER_STATE_CHANGED)
+
 	self:RegisterEvent('MODIFIER_STATE_CHANGED')
 	self:Hide()
-
-	for _, sparks in pairs(button.sparkles) do
-		sparks:SetHeight(sparks:GetHeight() * 2)
-		sparks:SetWidth(sparks:GetWidth() * 2)
-	end
 end

-function button:MODIFIER_STATE_CHANGED(event, key)
-	if(self:IsShown() and (key == 'LALT' or key == 'RALT')) then
-		OnLeave(self)
+function button:MODIFIER_STATE_CHANGED(key)
+	if(not self:IsShown() and not key and key ~= 'LALT' and key ~= 'RALT') then return end
+
+	if(InCombatLockdown()) then
+		self:RegisterEvent('PLAYER_REGEN_ENABLED')
+	else
+		self:ClearAllPoints()
+		self:Hide()
 	end
 end

-function button:PLAYER_REGEN_ENABLED(event)
-	self:UnregisterEvent(event)
-	OnLeave(self)
+function button:PLAYER_REGEN_ENABLED()
+	self:UnregisterEvent('PLAYER_REGEN_ENABLED')
+	self:ClearAllPoints()
+	self:Hide()
 end