WoWInterface SVN mikma

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /PoleVault
    from Rev 206 to Rev 211
    Reverse comparison

Rev 206 → Rev 211

PoleVault.lua
1,166 → 1,153
local eventbox = CreateFrame("Frame")
eventbox:RegisterEvent("PLAYER_ENTERING_WORLD")
eventbox:SetScript("OnEvent", function()
if UnitClass("player") == "Shaman" then
 
local Totems = {
[4] = {
3738, --"Wrath of Air Totem",
8512, --"Windfury Totem",
8177, --"Grounding Totem",
10595, --"Nature Resistance Totem",
6495, --"Sentry Totem",
36936 --"Totemic Call" -- NOT A TOTEM
},
[3] = {
5675, --"Mana Spring Totem",
5394, --"Healing Stream Totem",
8166, --"Poison Cleansing Totem",
8170, --"Disease Cleansing Totem",
8184, --"Fire Resistance Totem",
16190, --"Mana Tide Totem", -- TALENT
},
[2] = {
8075, --"Strength of Earth Totem",
8143, --"Tremor Totem",
5730, --"Stoneclaw Totem",
2484, --"Earthbind Totem",
8071, --"Stoneskin Totem",
2062, --"Earth Elemental Totem",
},
[1] = {
8227, --"Flametongue Totem",
8190, --"Magma Totem",
1535, --"Fire Nova Totem",
3599, --"Searing Totem",
2894, --"Fire Elemental Totem",
8181, --"Frost Reistance Totem",
30706, --"Totem of Wrath", -- TALENT
},
}
 
local previoustotem,temptotems
local a = 0.7
 
local function createtotembutton(spellID,type,r,g,b)
if GetSpellTexture(GetSpellInfo(spellID)) then
local button = CreateFrame("Button", GetSpellInfo(spellID), UIParent, "SecureActionButtonTemplate, ActionButtonTemplate")
_G[button:GetName().."Icon"]:SetTexture(GetSpellTexture(GetSpellInfo(spellID)))
button:RegisterForClicks("AnyUp")
button:SetAttribute("unit","player")
button:SetAttribute("type","spell")
button:SetAttribute("spell", GetSpellInfo(spellID))
button:SetPoint("LEFT", previoustotem, "RIGHT", 0, 0)
button:SetScale(0.87)
button:SetFrameStrata("HIGH")
_G[button:GetName().."NormalTexture"]:SetTexCoord(0,0,0,0)
local bg = CreateFrame("Frame")
bg:ClearAllPoints()
bg:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 0,edgeFile = "", edgeSize = 0,
insets = {left = 0, right = 0, top = 0, bottom = 0},})
bg:SetBackdropColor(r,g,b,a)
bg:SetPoint("TOPLEFT", button, "TOPLEFT")
bg:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT")
bg:SetFrameStrata("LOW")
bg:SetParent(UIParent)
_G[button:GetName().."Icon"]:SetTexCoord(0.07,0.93,0.07,0.93)
_G[button:GetName().."Icon"]:ClearAllPoints()
_G[button:GetName().."Icon"]:SetPoint("TOPLEFT", button, "TOPLEFT", 4, -4)
_G[button:GetName().."Icon"]:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -4, 4)
button:SetScript("OnEnter", function()
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
local name = GetSpellInfo(spellID)
local id = GetSpellLink(name):match('spell:(%d+)')
local rank = select(2,GetSpellInfo(id))
GameTooltip:SetHyperlink(GetSpellLink(id))
GameTooltipTextRight1:SetText(rank);
GameTooltipTextRight1:SetTextColor(0.5, 0.5, 0.5)
GameTooltipTextRight1:Show()
GameTooltip:Show()
end)
button:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
button:SetAttribute("type2", "DestroyTotem");
button.DestroyTotem = function() DestroyTotem(type);end
previoustotem = GetSpellInfo(spellID)
end
end
 
-- Totems go under the PlayerFrame in reverse order. Let's make the order match.
-- .""".-----------,
-- |^_^|-----------'
-- "---"(4)(3)(2)(1)
-- Slot4
local AnchorAir = CreateFrame("Button", nil, UIParent, "SecureActionButtonTemplate, ActionButtonTemplate")
AnchorAir:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", -36, 0)
AnchorAir:SetScale(0.87)
AnchorAir:Hide()
-- r,g,b = 0.86,0.86,0.86
previoustotem = AnchorAir
for slot,totem in pairs(Totems[4]) do
createtotembutton(totem,4,0.86,0.86,0.86)
end
 
-- Slot3
local AnchorWater = CreateFrame("Button", nil, UIParent, "SecureActionButtonTemplate, ActionButtonTemplate")
AnchorWater:SetPoint("BOTTOM", AnchorAir, "TOP")
AnchorWater:SetScale(0.87)
AnchorWater:Hide()
-- r,g,b = 0,0.6,1
previoustotem = AnchorWater
for slot,totem in pairs(Totems[3]) do
createtotembutton(totem,3,0,0.6,1)
end
 
-- Slot2
local AnchorEarth = CreateFrame("Button", nil, UIParent, "SecureActionButtonTemplate, ActionButtonTemplate")
AnchorEarth:SetPoint("BOTTOM", AnchorWater, "TOP")
AnchorEarth:SetScale(0.87)
AnchorEarth:Hide()
-- r,g,b = 0.8,0.4,0
previoustotem = AnchorEarth
for slot,totem in pairs(Totems[2]) do
createtotembutton(totem,2,0.8,0.4,0)
end
 
-- Slot1
local AnchorFire = CreateFrame("Button", nil, UIParent, "SecureActionButtonTemplate, ActionButtonTemplate")
AnchorFire:SetPoint("BOTTOM", AnchorEarth, "TOP")
AnchorFire:SetScale(0.87)
AnchorFire:Hide()
-- r,g,b = 1,0,0
previoustotem = AnchorFire
for slot,totem in pairs(Totems[1]) do
createtotembutton(totem,1,1,0,0)
end
 
-- eventbox:UnregisterEvent("PLAYER_ENTERING_WORLD")
eventbox:RegisterEvent("SPELL_UPDATE_COOLDOWN")
eventbox:RegisterEvent("PLAYER_TOTEM_UPDATE")
eventbox:SetScript("OnEvent", function(frame,event,arg1)
if event == "PLAYER_TOTEM_UPDATE" or event == "PLAYER_ENTERING_WORLD" then
for k,totem in pairs(Totems[arg1]) do
if GetSpellTexture(GetSpellInfo(totem)) then
_G[GetSpellInfo(totem)]:SetButtonState("NORMAL")
end
end
local _,name = GetTotemInfo(arg1)
local lol = string.match(name, "^(.*)%s[VXI]*$") or name
if lol ~= "" and lol ~= "Unknown" then
_G[lol]:SetButtonState("PUSHED")
end
elseif event == "SPELL_UPDATE_COOLDOWN" then
for type,v in pairs(Totems) do
for k,totem in pairs(v) do
if GetSpellTexture(GetSpellInfo(totem)) then
local start, duration, enable = GetSpellCooldown(GetSpellInfo(totem))
CooldownFrame_SetTimer(_G[GetSpellInfo(totem).."Cooldown"], start, duration, enable)
end
end
end
end
end)
 
end
end)
\ No newline at end of file +if select(2,UnitClass("player")) == "SHAMAN" then + + if not PoleVaultDB then PoleVaultDB = { PoleVaultEarth = {}, PoleVaultFire = {}, PoleVaultWater = {}, PoleVaultAir = {}, } end + + local Totems = { + spell = { + Earth = { 8071,2484,5730,8075,8143,2062, }, -- Stoneskin Totem, Earthbind Totem, Stoneclaw Totem, Strength of Earth Totem, Tremor Totem, Earth Elemental Totem + Fire = { 3599,1535,8181,8190,8227,2894,30706, }, -- Searing Totem, Fire Nova Totem, Frost Resistance Totem, Magma Totem, Flametongue Totem, Fire Elemental Totem, Totem of Wrath + Water = { 5394,8166,5675,8184,8170,16190, }, -- Healing Stream Totem, Poison Cleansing Totem, Mana Spring Totem, Fire Resistance Totem, Disease Cleansing Totem, Mana Tide Totem + Air = { 8177,10595,8512,6495,3738, }, -- Grounding Totem, Nature Resistance Totem, Windfury Totem, Sentry Totem, Wrath of Air Totem + }, + color = { + Earth = { 0.8,0.4,0, }, + Fire = { 1,0,0, }, + Water = { 0,0.6,1 }, + Air = { 1,1,1 }, + }, + blacklist = {} + } + + local PoleVault = CreateFrame("Frame","PoleVault") + PoleVault.frames = {} + PoleVault:RegisterEvent("PLAYER_ENTERING_WORLD") + PoleVault:SetScript("OnEvent", function(self) + + local function createanchor(name,color,width) + local frame = CreateFrame("Frame",name,UIParent) + frame:SetBackdrop(GameTooltip:GetBackdrop()) + frame:SetBackdropColor(unpack(Totems.color[color])) + frame:SetBackdropBorderColor(unpack(Totems.color[color])) + frame:SetWidth(width) + frame:SetHeight(43) + frame:SetFrameStrata("HIGH") + frame:SetFrameLevel(5) + frame:EnableMouse(true) + frame:SetMovable(true) + frame:SetUserPlaced(true) + frame:SetClampedToScreen(true) + frame:RegisterForDrag("LeftButton") + frame:SetScript("OnDragStart", function(self) + self:StartMoving() + end) + frame:SetScript("OnDragStop", function(self) + self:StopMovingOrSizing() + PoleVault:SavePosition(self) + end) + frame:Hide() + self.frames[name] = frame + end + + local function createtotembutton(number,spellID,name,type) + local button = CreateFrame("Button", name..number, UIParent, "SecureActionButtonTemplate, ActionButtonTemplate") + _G[button:GetName().."Icon"]:SetTexture(select(3,GetSpellInfo(spellID))) + button:RegisterForClicks("AnyUp") + button:SetAttribute("type","spell") + button:SetAttribute("spell", GetSpellInfo(spellID)) + button:SetFrameStrata("HIGH") + if not GetSpellTexture(GetSpellInfo(spellID)) then + Totems.blacklist[GetSpellInfo(spellID)] = name..number + button:Hide() + end + button:SetScript("OnEnter", function(self) + GameTooltip:SetOwner(self, "ANCHOR_RIGHT") + local name = GetSpellInfo(spellID) + local id = GetSpellLink(name):match('spell:(%d+)') + local rank = select(2,GetSpellInfo(id)) + GameTooltip:SetHyperlink("spell:"..id) + GameTooltipTextRight1:SetText(rank); + GameTooltipTextRight1:SetTextColor(0.5, 0.5, 0.5) + GameTooltipTextRight1:Show() + GameTooltip:Show() + end) + button:SetScript("OnLeave", function() GameTooltip:Hide() end) + button:SetAttribute("type2", "DestroyTotem"); + button.DestroyTotem = function() DestroyTotem(type);end + end + + createanchor("PoleVaultEarth","Earth",243) + createanchor("PoleVaultFire","Fire",283) + createanchor("PoleVaultWater","Water",243) + createanchor("PoleVaultAir","Air",203) + + for slot,totem in pairs(Totems.spell["Earth"]) do createtotembutton(slot,totem,"PoleVaultEarth",2) end + for slot,totem in pairs(Totems.spell["Fire"]) do createtotembutton(slot,totem,"PoleVaultFire",1) end + for slot,totem in pairs(Totems.spell["Water"]) do createtotembutton(slot,totem,"PoleVaultWater",3) end + for slot,totem in pairs(Totems.spell["Air"]) do createtotembutton(slot,totem,"PoleVaultAir",4) end + + PoleVaultEarth1:SetPoint("TOPLEFT",PoleVaultEarth,"TOPLEFT",4,-3) + PoleVaultFire1:SetPoint("TOPLEFT",PoleVaultFire,"TOPLEFT",4,-3) + PoleVaultWater1:SetPoint("TOPLEFT",PoleVaultWater,"TOPLEFT",4,-3) + PoleVaultAir1:SetPoint("TOPLEFT",PoleVaultAir,"TOPLEFT",4,-3) + + for i=2,6 do _G["PoleVaultEarth"..i]:SetPoint("LEFT","PoleVaultEarth"..i-1,"RIGHT",4,0) end + for i=2,7 do _G["PoleVaultFire"..i]:SetPoint("LEFT","PoleVaultFire"..i-1,"RIGHT",4,0) end + for i=2,6 do _G["PoleVaultWater"..i]:SetPoint("LEFT","PoleVaultWater"..i-1,"RIGHT",4,0) end + for i=2,5 do _G["PoleVaultAir"..i]:SetPoint("LEFT","PoleVaultAir"..i-1,"RIGHT",4,0) end + + for i=1,6 do _G["PoleVaultEarth"..i.."NormalTexture"]:SetVertexColor(unpack(Totems.color["Earth"])) end + for i=1,7 do _G["PoleVaultFire"..i.."NormalTexture"]:SetVertexColor(unpack(Totems.color["Fire"])) end + for i=1,6 do _G["PoleVaultWater"..i.."NormalTexture"]:SetVertexColor(unpack(Totems.color["Water"])) end + for i=1,5 do _G["PoleVaultAir"..i.."NormalTexture"]:SetVertexColor(unpack(Totems.color["Air"])) end + + function PoleVault:SavePosition(name) + local x,y = name:GetLeft(), name:GetTop() + local s = name:GetEffectiveScale() + x,y = x*s,y*s + PoleVaultDB[name:GetName()].x = x + PoleVaultDB[name:GetName()].y = y + end + + function PoleVault:RestorePosition(name) + local x = PoleVaultDB[name].x + local y = PoleVaultDB[name].y + local s = _G[name]:GetEffectiveScale() + if not x or not y then + local random1 = math.random(-50,50) + local random2 = math.random(-50,50) + _G[name]:ClearAllPoints() + _G[name]:SetPoint("CENTER", UIParent, "CENTER", random1, random2) + return + end + x,y = x/s,y/s + _G[name]:ClearAllPoints() + _G[name]:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", x, y) + end + + for k,v in pairs(self.frames) do + self:RestorePosition(k) + end + + local function unlock() + for k,v in pairs(self.frames) do + v:Show() + v:SetMovable(true) + end + end + + local function lock() + for k,v in pairs(self.frames) do + v:Hide() + v:SetMovable(false) + end + end + + SLASH_POLEVAULT1 = "/pv" + SLASH_POLEVAULT2 = "/polevault" + SlashCmdList["POLEVAULT"] = function(arg1) + if arg1 == "unlock" then unlock() + elseif arg1 == "lock" then lock() + else DEFAULT_CHAT_FRAME:AddMessage("use 'lock' or 'unlock'") end + end + end) +end \ No newline at end of file
PoleVault.toc
1,4 → 1,5
## Interface: 30000
## Title: PoleVault
## Notes: Simple Totem Bar
## SavedVariables: PoleVaultDB
PoleVault.lua
\ No newline at end of file