WoWInterface SVN mikma

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /Voodoo
    from Rev 551 to Rev 552
    Reverse comparison

Rev 551 → Rev 552

Voodoo.lua
1,7 → 1,9
AddOn = "|cFFFF7733Voodoo:|r "
BINDING_HEADER_VOODOO = "Voodoo"
setglobal("BINDING_NAME_CLICK Voodoo:LeftButton", "Execute")
 
local frame = CreateFrame("Button",nil,UIParent)
local anchor = CreateFrame("Frame",nil,UIParent)
local frame = CreateFrame("Button","VoodooFrame",UIParent)
frame:SetScript("OnEvent", function(self, event, ...)
if self[event] then return self[event](self, event, ...) end
end)
10,7 → 12,7
local button = CreateFrame("Button", "Voodoo", UIParent, "SecureActionButtonTemplate, ActionButtonTemplate")
button:SetPoint("CENTER",UIParent)
 
local wait,timer = 0.3,0
local wait,timer,scalevalue,oldtext = 0.3,0
 
local function ChangeButtonAttributes(texture,actiontype,spell,target)
if texture then
27,7 → 29,10
end
 
local function ChangeAction()
if InCombatLockdown() then return end
if InCombatLockdown() then
Print(AddOn.."Sorry, you can't change the button in combat.")
return
end
local actiontype,itemID = GetCursorInfo()
if actiontype == "spell" or "item" then
VoodooDB[GetActiveTalentGroup()]["actiontype"] = actiontype
104,54 → 109,133
self:ClearFocus()
end)
editbox:SetScript("OnEscapePressed", function(self)
editbox:SetText(oldtext)
self:ClearFocus()
end)
editbox:SetScript("OnEditFocusGained", function(self)
if InCombatLockdown() then
self:ClearFocus()
Print(AddOn.."Sorry, you can't change the target in combat.")
return
end
VoodooDB[GetActiveTalentGroup()]["target"] = self:GetText() ~= "" and self:GetText() or nil
ChangeButtonAttributes(VoodooDB[GetActiveTalentGroup()]["texture"],VoodooDB[GetActiveTalentGroup()]["actiontype"],VoodooDB[GetActiveTalentGroup()]["spell"],VoodooDB[GetActiveTalentGroup()]["target"])
self:ClearFocus()
end)
editbox:SetScript("OnEditFocusGained", function(self)
if InCombatLockdown() then return end
if IsShiftKeyDown() and UnitExists("target") then
VoodooDB[GetActiveTalentGroup()]["target"] = UnitName("target")
ChangeButtonAttributes(VoodooDB[GetActiveTalentGroup()]["texture"],VoodooDB[GetActiveTalentGroup()]["actiontype"],VoodooDB[GetActiveTalentGroup()]["spell"],VoodooDB[GetActiveTalentGroup()]["target"])
self:SetText(VoodooDB[GetActiveTalentGroup()]["target"])
self:ClearFocus()
else
oldtext = self:GetText()
self:HighlightText()
end
end)
 
local function GetTipAnchor(frame)
local x,y = frame:GetCenter()
if not x or not y then return "TOPLEFT", frame, "BOTTOMLEFT" end
local hhalf = (x > UIParent:GetWidth()*2/3) and "RIGHT" or (x < UIParent:GetWidth()/3) and "LEFT" or ""
local vhalf = (y > UIParent:GetHeight()/2) and "TOP" or "BOTTOM"
return vhalf..hhalf, frame, (vhalf == "TOP" and "BOTTOM" or "TOP")..hhalf
end
 
local function MyTooltip(frame)
GameTooltip:SetOwner(frame, "ANCHOR_NONE")
GameTooltip:SetPoint(GetTipAnchor(frame))
GameTooltip:ClearLines()
GameTooltip:AddLine("Voodoo Help:",1,0.47,0.2)
GameTooltip:AddLine("Frame Unlocked (Red background):",1,1,1)
GameTooltip:AddDoubleLine("Shift+Doubleclick:","Lock on")
GameTooltip:AddDoubleLine("Mousewheel:","Change scale (0.1)")
GameTooltip:AddDoubleLine("Shift+Mousewheel:","Change scale (0.01)")
GameTooltip:AddLine("Frame Locked (Black background):",1,1,1)
GameTooltip:AddDoubleLine("Shift+Doubleclick:","Lock off")
GameTooltip:AddLine("Editbox:",1,1,1)
GameTooltip:AddDoubleLine("Shift+click:","Use target name")
GameTooltip:AddDoubleLine("Click","Edit the target name")
GameTooltip:AddDoubleLine("Enter (edit active)","Accept the name")
GameTooltip:AddDoubleLine("Esc (edit active)","Cancel the change")
GameTooltip:Show()
end
 
local text = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
text:SetWidth(100)
text:SetHeight(30)
text:SetPoint("BOTTOM",frame,"TOP",0,-5)
anchor:SetWidth(1)
anchor:SetHeight(1)
anchor:SetMovable(true)
anchor:SetUserPlaced(true)
frame:SetBackdrop(GameTooltip:GetBackdrop())
frame:SetBackdropColor(1,0,0,0.5)
frame:SetBackdropBorderColor(1,1,1,1)
frame:RegisterForDrag("LeftButton")
frame:SetMovable(true)
frame:EnableMouse(true)
frame:SetUserPlaced(true)
frame:EnableMouseWheel(true)
frame:SetClampedToScreen(true)
frame:SetParent(UIParent)
frame:SetScript("OnDragStart", function(self)
if not VoodooDB.lock then
self:StartMoving()
anchor:StartMoving()
end
end)
frame:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
VoodooDB.point, VoodooDB.x, VoodooDB.y = "BOTTOMLEFT", self:GetLeft(), self:GetBottom()
anchor:StopMovingOrSizing()
VoodooDB.point, VoodooDB.x, VoodooDB.y = "BOTTOMLEFT", anchor:GetLeft(), anchor:GetBottom()
end)
frame:SetScript("OnDoubleClick", function(self)
if IsShiftKeyDown() then
VoodooDB.lock = not VoodooDB.lock
if VoodooDB.lock then
frame:SetBackdropColor(0,0,0,0.5)
text:Hide()
GameTooltip:Hide()
else
frame:SetBackdropColor(1,0,0,0.5)
text:Show()
MyTooltip(self)
end
end
end)
frame:SetScript("OnMouseWheel", function(self,value)
if not VoodooDB.lock then
if IsShiftKeyDown() then scalevalue = 0.01 else scalevalue = 0.1 end
if value > 0 and VoodooDB.scale <= 2 then
VoodooDB.scale = VoodooDB.scale + scalevalue
elseif value < 0 and VoodooDB.scale >= 0.6 then
VoodooDB.scale = VoodooDB.scale - scalevalue
end
self:SetScale(VoodooDB.scale)
text:SetText("Scale: "..VoodooDB.scale)
else
return
end
end)
 
frame:SetScript("OnEnter", function(self)
if not VoodooDB.lock then
MyTooltip(self)
-- GameTooltip:SetOwner(self, "ANCHOR_NONE")
-- GameTooltip:SetPoint(GetTipAnchor(self))
-- GameTooltip:ClearLines()
-- GameTooltip:AddLine("Voodoo Help:",1,0.47,0.2)
-- GameTooltip:AddLine("Frame Unlocked (Red background):",1,1,1)
-- GameTooltip:AddDoubleLine("Shift+Doubleclick:","Lock on")
-- GameTooltip:AddDoubleLine("Mousewheel:","Change scale (0.1)")
-- GameTooltip:AddDoubleLine("Shift+Mousewheel:","Change scale (0.01)")
-- GameTooltip:AddLine("Frame Locked (Black background):",1,1,1)
-- GameTooltip:AddDoubleLine("Shift+Doubleclick:","Lock off")
-- GameTooltip:AddLine("Editbox:",1,1,1)
-- GameTooltip:AddDoubleLine("Shift+click:","Use target name")
-- GameTooltip:AddDoubleLine("Click","Edit the target name")
-- GameTooltip:AddDoubleLine("Enter (edit active)","Accept the name")
-- GameTooltip:AddDoubleLine("Esc (edit active)","Cancel the change")
-- GameTooltip:Show()
end
end)
frame:SetScript("OnLeave", function()
if not VoodooDB.lock then
GameTooltip:Hide()
end
end)
 
local function onUpdate(self,elapsed)
timer = timer + elapsed
if timer >= wait then
167,36 → 251,29
end
 
local function SetPosition()
frame:SetPoint("TOPLEFT",Voodoo,"TOPLEFT",-7,7)
frame:SetPoint("BOTTOMLEFT",Voodoo,"BOTTOMLEFT",-7,-7)
frame:SetPoint("RIGHT",MyLittleEditbox,"RIGHT",7,0)
local width = frame:GetWidth()
local height = frame:GetHeight()
anchor:SetPoint(VoodooDB.point and VoodooDB.point or "CENTER", VoodooDB.x and VoodooDB.x or UIParent, VoodooDB.y and VoodooDB.y or nil)
frame:ClearAllPoints()
frame:SetPoint(VoodooDB.point and VoodooDB.point or "CENTER", VoodooDB.x and VoodooDB.x or UIParent, VoodooDB.y and VoodooDB.y or nil)
frame:SetWidth(width)
frame:SetHeight(height)
frame:SetPoint("CENTER",anchor,"CENTER")
frame:SetWidth(159)
frame:SetHeight(50)
frame:SetScale(VoodooDB.scale)
button:ClearAllPoints()
button:SetPoint("TOPLEFT",frame,"TOPLEFT",7,-7)
button:SetParent(frame)
editbox:SetParent(frame)
text:SetText("Scale: "..VoodooDB.scale)
end
 
local function GetSpellData()
function frame:SPELL_UPDATE_COOLDOWN()
CheckCooldown()
end
 
function frame:PLAYER_TALENT_UPDATE()
if not VoodooDB[GetActiveTalentGroup()] then VoodooDB[GetActiveTalentGroup()] = {} end
local texture = VoodooDB[GetActiveTalentGroup()]["texture"] and VoodooDB[GetActiveTalentGroup()]["texture"] or "Interface\\Icons\\INV_Misc_QuestionMark"
local actiontype = VoodooDB[GetActiveTalentGroup()]["actiontype"] and VoodooDB[GetActiveTalentGroup()]["actiontype"] or nil
local spell = VoodooDB[GetActiveTalentGroup()]["spell"] and VoodooDB[GetActiveTalentGroup()]["spell"] or nil
local target = VoodooDB[GetActiveTalentGroup()]["target"] and VoodooDB[GetActiveTalentGroup()]["target"] or ""
return texture,actiontype,spell,target
end
 
function frame:SPELL_UPDATE_COOLDOWN()
CheckCooldown()
end
 
function frame:PLAYER_TALENT_UPDATE()
local texture,actiontype,spell,target = GetSpellData()
ChangeButtonAttributes(texture,actiontype,spell,target)
CheckCooldown()
end
216,7 → 293,7
end
 
function frame:PLAYER_LOGIN()
if not VoodooDB then VoodooDB = {} end
if not VoodooDB then VoodooDB = {scale = 1} end
if not VoodooDB[GetActiveTalentGroup()] then VoodooDB[GetActiveTalentGroup()] = {} end
if VoodooDB[GetActiveTalentGroup()]["spell"] and VoodooDB[GetActiveTalentGroup()]["texture"] then
ChangeButtonAttributes(VoodooDB[GetActiveTalentGroup()]["texture"],VoodooDB[GetActiveTalentGroup()]["actiontype"],VoodooDB[GetActiveTalentGroup()]["spell"],VoodooDB[GetActiveTalentGroup()]["target"])
224,8 → 301,10
editbox:SetText(VoodooDB[GetActiveTalentGroup()]["target"] and VoodooDB[GetActiveTalentGroup()]["target"] or "")
if VoodooDB.lock then
frame:SetBackdropColor(0,0,0,0.5)
text:Hide()
else
frame:SetBackdropColor(1,0,0,0.5)
text:Show()
end
SetPosition()
frame:RegisterEvent("PLAYER_TALENT_UPDATE")