From 29c5661321956afa74bd5fb2543fc5823ece3d90 Mon Sep 17 00:00:00 2001 From: Aleksi Blinnikka Date: Tue, 25 Aug 2020 23:52:35 +0300 Subject: [PATCH] Add stance bar, remove azerite bar --- OmaAB/AzeriteBar.lua | 38 ------ OmaAB/Bindings.xml | 287 +++++++++++++++++++++-------------------- OmaAB/HideBlizzard.lua | 4 +- OmaAB/OmaAB.toc | 2 +- OmaAB/StanceBar.lua | 78 +++++++++++ 5 files changed, 226 insertions(+), 183 deletions(-) delete mode 100644 OmaAB/AzeriteBar.lua create mode 100644 OmaAB/StanceBar.lua diff --git a/OmaAB/AzeriteBar.lua b/OmaAB/AzeriteBar.lua deleted file mode 100644 index 4989652..0000000 --- a/OmaAB/AzeriteBar.lua +++ /dev/null @@ -1,38 +0,0 @@ --- AzeriteBar.lua -local _; -local width = 300; -local running = false; -local frame = CreateFrame("Frame", "OmaAzeriteBar", UIParent); - -frame:SetScript("OnEvent", function() - frame:SetPoint("BOTTOM"); - frame:SetWidth(width); - frame:SetHeight(8); - frame.base = frame:CreateTexture(nil, "BACKGROUND"); - frame.base:SetAllPoints(); - frame.base:SetColorTexture(0, 0, 0, 0.5); - frame.bar = frame:CreateTexture(nil, "BORDER"); - frame.bar:SetPoint("TOPLEFT", frame.base, "TOPLEFT"); - frame.bar:SetPoint("BOTTOMLEFT", frame.base, "BOTTOMLEFT"); - frame.bar:SetColorTexture(ARTIFACT_BAR_COLOR:GetRGB()); - frame.text = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlight"); - frame.text:SetPoint("BOTTOM"); - frame.text:Hide(); - - frame:SetScript("OnEvent", function() - -- from FrameXML/AzeriteBar.lua - local azeriteItem = C_AzeriteItem.FindActiveAzeriteItem(); - if not azeriteItem then return end - - local xp, totalxp = C_AzeriteItem.GetAzeriteItemXPInfo(azeriteItem); - frame.bar:SetWidth(xp/totalxp*width); - frame.text:SetFormattedText("%d / %d", xp, totalxp); - end); - frame:UnregisterAllEvents(); - frame:RegisterEvent("PLAYER_ENTERING_WORLD"); - frame:RegisterEvent("AZERITE_ITEM_EXPERIENCE_CHANGED"); - -- from FrameXML/MainMenuBar.lua - frame:SetScript("OnEnter", function(frame) frame.text:Show(); end); - frame:SetScript("OnLeave", function(frame) frame.text:Hide(); end); -end); -frame:RegisterEvent("PLAYER_LOGIN"); diff --git a/OmaAB/Bindings.xml b/OmaAB/Bindings.xml index 7ae37aa..5c15425 100644 --- a/OmaAB/Bindings.xml +++ b/OmaAB/Bindings.xml @@ -1,142 +1,145 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OmaAB/HideBlizzard.lua b/OmaAB/HideBlizzard.lua index 99eb825..d2524ce 100644 --- a/OmaAB/HideBlizzard.lua +++ b/OmaAB/HideBlizzard.lua @@ -93,11 +93,11 @@ local function hide() ZoneAbilityFrame:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -450, 150); ExtraActionBarFrame:ClearAllPoints(); ExtraActionBarFrame:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -450, 120); - --[[StanceBarFrame:UnregisterAllEvents() + StanceBarFrame:UnregisterAllEvents() StanceBarFrame:Hide() StanceBarFrame:SetParent(UIHider) - --BonusActionBarFrame:UnregisterAllEvents() + --[[--BonusActionBarFrame:UnregisterAllEvents() --BonusActionBarFrame:Hide() --BonusActionBarFrame:SetParent(UIHider) diff --git a/OmaAB/OmaAB.toc b/OmaAB/OmaAB.toc index ac0a169..0190f10 100644 --- a/OmaAB/OmaAB.toc +++ b/OmaAB/OmaAB.toc @@ -7,5 +7,5 @@ HideBlizzard.lua Bindings.xml ExpBar.lua -AzeriteBar.lua ActionBars.lua +StanceBar.lua diff --git a/OmaAB/StanceBar.lua b/OmaAB/StanceBar.lua new file mode 100644 index 0000000..afb5cc6 --- /dev/null +++ b/OmaAB/StanceBar.lua @@ -0,0 +1,78 @@ +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,3 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(); + for i=1,3 do + create(i, self, self[i-1]); + end + update(self); + _G["BINDING_HEADER_OMAABSTANCE"] = "Stance Bar"; + for i = 1,3 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(); -- 2.39.5