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) |