local _; local format = string.format; local stancebar = CreateFrame("Frame", "OmaStanceBar", UIParent); function create(slot, bar, prev) local frame = CreateFrame("CheckButton", "OmaBTStance"..slot, bar, "StanceButtonTemplate"); bar[slot] = frame; frame:SetID(slot); frame:SetWidth(32); frame:SetHeight(32); frame:GetNormalTexture():SetTexture(""); frame.cooldown = { SetSwipeColor = function() end, }; frame.base = frame:CreateTexture(nil, "BACKGROUND"); frame.base:SetAllPoints(); frame.base:SetColorTexture(0, 0, 0, 0.5); frame.icon = frame:CreateTexture(nil, "ARTWORK"); frame.icon:SetPoint("TOPLEFT", frame.base, "TOPLEFT", 1, -1); frame.icon:SetPoint("BOTTOMRIGHT", frame.base, "BOTTOMRIGHT", -1, 1); frame.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93); if slot == 1 then frame:SetPoint("TOPLEFT"); else frame:SetPoint("TOPLEFT", prev, "TOPRIGHT"); end frame:RegisterForClicks("AnyUp"); end -- FIXME if more stances necessary use NUM_STANCE_SLOTS for the max, paladins have 3 function update(bar) local n = GetNumShapeshiftForms(); --for i=1,NUM_STANCE_SLOTS do for i=1,4 do local button = bar[i]; if i <= n then local tex, active, castable = GetShapeshiftFormInfo(i); local icon = button.icon; icon:SetTexture(tex); if active then button:SetChecked(true); else button:SetChecked(false); end if castable then icon:SetVertexColor(1, 1, 1); else icon:SetVertexColor(0.4, 0.4, 0.4); end --button:Show(); else --button:Hide(); end end end stancebar:SetScript("OnEvent", function(self, event) if event == "UPDATE_SHAPESHIFT_COOLDOWN" then update(self); elseif event == "PLAYER_LOGIN" then -- TODO do class detection and only create necessary buttons stancebar:UnregisterAllEvents(); local _, class = UnitClass("player"); if class ~= "PALADIN" and class ~= "DRUID" then return end for i=1,4 do create(i, self, self[i-1]); end update(self); _G["BINDING_HEADER_OMAABSTANCE"] = "Stance Bar"; for i = 1,4 do _G[format("BINDING_NAME_CLICK OmaBTStance%d:LeftButton", i)] = format("Stance Bar Button %d", i); end stancebar:RegisterEvent("UPDATE_SHAPESHIFT_COOLDOWN"); end end); stancebar:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 580, 40); stancebar:SetFrameStrata("LOW"); stancebar:SetWidth(1); stancebar:SetHeight(1); stancebar:RegisterEvent("PLAYER_LOGIN"); stancebar:Show();