From: Aleksi Blinnikka Date: Thu, 1 Feb 2018 21:03:48 +0000 (+0200) Subject: Refector indicators to be more flexible X-Git-Url: https://www.aleksib.fi/git/wowui.git/commitdiff_plain/001062c21d0a4b6600278f45ee096fc587c745df?ds=sidebyside Refector indicators to be more flexible Now separate indicator setup based on class allowing different layouts. --- diff --git a/OmaRF/DruidIndicators.lua b/OmaRF/DruidIndicators.lua new file mode 100644 index 0000000..f956791 --- /dev/null +++ b/OmaRF/DruidIndicators.lua @@ -0,0 +1,52 @@ +-- DruidIndicators.lua +local pairs = pairs; + +local indSize = OmaRFSettings.IndSize; +local rhomb = "Interface\\AddOns\\OmaRF\\images\\rhomb"; +local square = "Interface\\AddOns\\OmaRF\\images\\square"; +local positions = {"TOPLEFT"}; + +local M = {}; +OmaRFIndicators.Class["Druid"] = M; +M.Auras = { + ["Lifebloom"] = "TOPLEFT", + ["Rejuvenation"] = "TR1", + ["Cenarion Ward"] = "TR2", + ["Spring Blossoms"] = "TR3", + ["Regrowth"] = "TR4", + ["Cultivation"] = "TR5", +} + +function M.Setup(base) + local inds = {}; + for _, pos in pairs(positions) do + inds[pos] = base:CreateTexture(nil, "OVERLAY"); + inds[pos]:SetPoint(pos, base, pos); + inds[pos]:SetWidth(indSize); + inds[pos]:SetHeight(indSize); + inds[pos]:SetTexture(rhomb); + inds[pos]:SetVertexColor(0, 1, 0); + inds[pos]:Hide(); + inds[pos].text = base:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); + inds[pos].text:SetPoint("BOTTOMRIGHT", inds[pos], "BOTTOMRIGHT"); + inds[pos].text:Hide(); + end + for _, pos in pairs({"TR1", "TR2", "TR3", "TR4", "TR5"}) do + inds[pos] = base:CreateTexture(nil, "OVERLAY"); + inds[pos]:SetWidth(indSize/2); + inds[pos]:SetHeight(indSize/2); + inds[pos]:SetTexture(square); + inds[pos]:Hide(); + end + inds["TR1"]:SetPoint("TOPRIGHT"); + inds["TR1"]:SetVertexColor(0.8, 0, 1); + inds["TR2"]:SetPoint("TOPRIGHT", inds["TR1"], "TOPLEFT"); + inds["TR2"]:SetVertexColor(0.4, 1, 0); + inds["TR3"]:SetPoint("TOPRIGHT", inds["TR1"], "BOTTOMRIGHT"); + inds["TR3"]:SetVertexColor(1, 0.2, 0); + inds["TR4"]:SetPoint("TOPRIGHT", inds["TR2"], "BOTTOMRIGHT"); + inds["TR4"]:SetVertexColor(0, 1, 0); + inds["TR5"]:SetPoint("TOPRIGHT", inds["TR3"], "BOTTOMRIGHT"); + inds["TR5"]:SetVertexColor(0, 1, 0.5); + return inds; +end diff --git a/OmaRF/Indicators.lua b/OmaRF/Indicators.lua index 3ecdcf6..6b4e04a 100644 --- a/OmaRF/Indicators.lua +++ b/OmaRF/Indicators.lua @@ -8,9 +8,7 @@ local CTimerAfter = C_Timer.After; local Settings = OmaRFSettings; local majorAuras = Settings.MajorAuras; -local indSize = Settings.IndSize; -local positions = nil; -local watchedAuras = nil; +local watchedAuras = {}; local updaters = {}; local updating = {}; @@ -18,47 +16,39 @@ local auraFilters = {"HELPFUL", "HARMFUL"}; local M = {}; OmaRFIndicators = M; +M.Class = {}; -function M.SetupIndicators(frame) - if not watchedAuras then - watchedAuras = Settings.Character["WatchedAuras"]; - positions = Settings.Character.Positions; +function M.SetupIndicators(frame, class) + frame.indBase = CreateFrame("Frame", nil, frame); + frame.indBase:SetAllPoints(); + frame.indBase:Hide(); + if M.Class[class] then + watchedAuras = M.Class[class].Auras; + frame.inds = M.Class[class].Setup(frame.indBase); + else + frame.inds = {}; end - frame.inds = CreateFrame("Frame", nil, frame); - frame.inds:SetAllPoints(); - frame.inds:Hide(); - for _, pos in pairs(positions) do - frame.inds[pos] = frame.inds:CreateTexture(nil, "OVERLAY"); - frame.inds[pos]:SetPoint(pos, frame.inds, pos); - frame.inds[pos]:SetWidth(indSize); - frame.inds[pos]:SetHeight(indSize); - frame.inds[pos]:SetTexture("Interface\\AddOns\\OmaRF\\images\\rhomb"); - frame.inds[pos]:SetVertexColor(1, 0, 0); - frame.inds[pos]:Hide(); - frame.inds[pos].text = frame.inds:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); - frame.inds[pos].text:SetPoint("BOTTOMRIGHT", frame.inds[pos], "BOTTOMRIGHT"); - frame.inds[pos].text:Hide(); - end - frame.major = CreateFrame("Frame", nil, frame); - frame.major:SetPoint("TOPLEFT", frame, "TOPLEFT", 4, -indSize + 4); - frame.major:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT"); + frame.majorBase = CreateFrame("Frame", nil, frame); + frame.majorBase:SetPoint("TOPLEFT", frame, "TOPLEFT", 4, -10); + frame.majorBase:SetPoint("BOTTOMRIGHT"); + frame.majors = {}; for i = 1,3 do - frame.major[i] = frame.major:CreateTexture(nil, "OVERLAY"); - if i == 1 then - frame.major[i]:SetPoint("TOPLEFT", frame.major, "TOPLEFT"); - else - frame.major[i]:SetPoint("TOPLEFT", frame.major[i-1], "TOPRIGHT"); - end - frame.major[i]:SetWidth(indSize*2); - frame.major[i]:SetHeight(indSize*2); - frame.major[i]:Hide(); - frame.major[i].text = frame.major:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); - frame.major[i].text:SetPoint("BOTTOMRIGHT", frame.major[i], "BOTTOMRIGHT"); - frame.major[i].text:Hide(); - frame.major[i].stack = frame.major:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); - frame.major[i].stack:SetPoint("TOPLEFT", frame.major[i], "TOPLEFT"); - frame.major[i].stack:Hide(); + local tex = frame.majorBase:CreateTexture(nil, "OVERLAY"); + tex = frame.majorBase:CreateTexture(nil, "OVERLAY"); + if i == 1 then tex:SetPoint("TOPLEFT", frame.majorBase, "TOPLEFT"); + else tex:SetPoint("TOPLEFT", frame.majors[i-1], "TOPRIGHT"); end + tex:SetWidth(20); + tex:SetHeight(20); + tex:Hide(); + tex.text = frame.majorBase:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); + tex.text:SetPoint("CENTER", tex, "BOTTOMRIGHT", -2, 2); + tex.text:Hide(); + tex.stack = frame.majorBase:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); + tex.stack:SetPoint("CENTER", tex, "TOPLEFT", 1, 0); + tex.stack:Hide(); + tex.icon = true; + frame.majors[i] = tex; end end @@ -76,7 +66,8 @@ local function remaining(text, expires, current) return true; end -local function updateIndicators(frame, unit) +local function updateIndicators(frame) + local unit = frame.displayed; if not frame:IsShown() or not UnitIsConnected(unit) or UnitIsDeadOrGhost(unit) then updating[frame] = nil; return; @@ -84,16 +75,14 @@ local function updateIndicators(frame, unit) local needUpdate = false; local current = GetTime(); - for _, pos in pairs(positions) do - local ind = frame.inds[pos]; - if ind.expires ~= nil then - needUpdate = remaining(ind.text, ind.expires, current) or needUpdate; + for _, ind in pairs(frame.inds) do + if ind.text and ind.text.expires ~= nil then + needUpdate = remaining(ind.text, ind.text.expires, current) or needUpdate; end end - for i = 1,3 do - local ind = frame.major[i]; - if ind.expires ~= nil then - needUpdate = remaining(ind.text, ind.expires, current) or needUpdate; + for _, ind in pairs(frame.majors) do + if ind.text and ind.text.expires ~= nil then + needUpdate = remaining(ind.text, ind.text.expires, current) or needUpdate; end end if needUpdate then @@ -103,17 +92,39 @@ local function updateIndicators(frame, unit) end end +local function showInd(ind, expires, current, count, icon) + local needUpdate = false; + if ind.icon then + ind:SetTexture(icon); + end + if ind.text then + needUpdate = remaining(ind.text, expires, current); + ind.text.expires = expires; + ind.text:Show(); + end + if ind.stack and count > 1 then + ind.stack:SetText(count); + ind.stack:Show(); + end + ind:Show(); + return needUpdate; +end + +local function hideInd(ind) + if ind.text then + ind.text.expires = nil; + ind.text:Hide(); + end + if ind.stack then ind.stack:Hide() end + ind:Hide(); +end + function M.CheckIndicators(frame, unit) - for _, pos in pairs(positions) do - frame.inds[pos].expires = nil; - frame.inds[pos]:Hide(); - frame.inds[pos].text:Hide(); + for _, ind in pairs(frame.inds) do + hideInd(ind); end - for i = 1,3 do - frame.major[i].expires = nil; - frame.major[i]:Hide(); - frame.major[i].text:Hide(); - frame.major[i].stack:Hide(); + for _, ind in pairs(frame.majors) do + hideInd(ind); end local name, icon, count, expires, caster, id; local showInds, showMajors, needUpdate = false, false, false; @@ -127,26 +138,13 @@ function M.CheckIndicators(frame, unit) if not id then break end local pos = watchedAuras[id] or watchedAuras[name]; if pos and caster == "player" then - needUpdate = remaining(frame.inds[pos].text, expires, current); - frame.inds[pos].expires = expires; - frame.inds[pos]:Show(); - frame.inds[pos].text:Show(); + needUpdate = showInd(frame.inds[pos], expires, current, count, icon) or needUpdate; showInds = true; end local major = majorAuras[id] or majorAuras[name]; if major and majorPos <= 3 then - needUpdate = remaining(frame.major[majorPos].text, expires, current); - frame.major[majorPos].expires = expires; - frame.major[majorPos]:SetTexture(icon); - frame.major[majorPos]:Show(); - frame.major[majorPos].text:Show(); - if count > 1 then - frame.major[majorPos].stack:SetText(count); - frame.major[majorPos].stack:Show(); - end - if major.bar then - alert = true; - end + needUpdate = showInd(frame.majors[majorPos], expires, current, count, icon) or needUpdate; + if major.bar then alert = true end showMajors = true; majorPos = majorPos + 1; end @@ -154,21 +152,21 @@ function M.CheckIndicators(frame, unit) end end if showInds or showMajors then - frame.inds:Show(); - frame.major:Show(); + frame.indBase:Show(); + frame.majorBase:Show(); if needUpdate and not updating[frame] then updating[frame] = true; -- race? -- create a function for updating the indicator local func = updaters[frame]; if not func then - func = function() updateIndicators(frame, unit) end; + func = function() updateIndicators(frame) end; updaters[frame] = func; end CTimerAfter(0.16, func); end else - frame.inds:Hide(); - frame.major:Hide(); + frame.indBase:Hide(); + frame.majorBase:Hide(); end return alert; diff --git a/OmaRF/OmaRF.toc b/OmaRF/OmaRF.toc index a8140c8..b7d7326 100644 --- a/OmaRF/OmaRF.toc +++ b/OmaRF/OmaRF.toc @@ -6,5 +6,7 @@ Settings.lua Indicators.lua +DruidIndicators.lua +PaladinIndicators.lua Events.lua RaidFrame.lua diff --git a/OmaRF/PaladinIndicators.lua b/OmaRF/PaladinIndicators.lua new file mode 100644 index 0000000..becda9b --- /dev/null +++ b/OmaRF/PaladinIndicators.lua @@ -0,0 +1,37 @@ +-- PaladinIndicators.lua +local pairs = pairs; + +local indSize = OmaRFSettings.IndSize; +local rhomb = "Interface\\AddOns\\OmaRF\\images\\rhomb"; +local positions = {"TOPRIGHT", "BOTTOMLEFT"}; + +local M = {}; +OmaRFIndicators.Class["Paladin"] = M; +M.Auras = { + [53563] = "TOPRIGHT", -- Beacon of Light + [156910] = "TOPRIGHT", -- Beacon of Faith + [200025] = "TOPRIGHT", -- Beacon of Virtue + [200654] = "BOTTOMLEFT", -- Tyr's Deliverance +} + +function M.Setup(base) + local inds = {}; + inds["TOPRIGHT"] = base:CreateTexture(nil, "OVERLAY"); + inds["TOPRIGHT"]:SetPoint("TOPRIGHT", base, "TOPRIGHT"); + inds["TOPRIGHT"]:SetWidth(indSize); + inds["TOPRIGHT"]:SetHeight(indSize); + inds["TOPRIGHT"]:SetTexture(rhomb); + inds["TOPRIGHT"]:SetVertexColor(1, 0, 0); + inds["TOPRIGHT"]:Hide(); + inds["BOTTOMLEFT"] = base:CreateTexture(nil, "OVERLAY"); + inds["BOTTOMLEFT"]:SetPoint("BOTTOMLEFT", base, "BOTTOMLEFT"); + inds["BOTTOMLEFT"]:SetWidth(indSize); + inds["BOTTOMLEFT"]:SetHeight(indSize); + inds["BOTTOMLEFT"]:SetTexture(rhomb); + inds["BOTTOMLEFT"]:SetVertexColor(1, 0.5, 0); + inds["BOTTOMLEFT"]:Hide(); + inds["BOTTOMLEFT"].text = base:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); + inds["BOTTOMLEFT"].text:SetPoint("BOTTOMRIGHT", inds["BOTTOMLEFT"], "BOTTOMRIGHT"); + inds["BOTTOMLEFT"].text:Hide(); + return inds; +end diff --git a/OmaRF/RaidFrame.lua b/OmaRF/RaidFrame.lua index ad802cb..955c816 100644 --- a/OmaRF/RaidFrame.lua +++ b/OmaRF/RaidFrame.lua @@ -30,6 +30,7 @@ local attributes = {}; local CFrame = CreateFrame("Frame", "OmaRFFrame", UIParent); local inheritedFrames = "SecureUnitButtonTemplate,SecureHandlerStateTemplate"; +local class = nil; local party = {}; local raid = {}; @@ -146,7 +147,7 @@ local function setupFrame(frame, secure, unit) frame.ready:SetPoint("BOTTOMRIGHT", frame.background, "BOTTOMLEFT", 14, 0); frame.ready:Hide(); -- set up indicators - setupIndicators(frame); + setupIndicators(frame, class); -- set scripts frame:SetScript("OnShow", frameShow); frame:SetScript("OnHide", frameHide); @@ -273,6 +274,7 @@ local function initialize() GameTooltip = _G["GameTooltip"]; GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"]; loadCharSettings(); + class = UnitClass("player"); CFrame:SetPoint("CENTER", nil, "CENTER", anchorX, anchorY); CFrame:SetHeight((height+2)*8); CFrame:SetWidth((width+2)*5); diff --git a/OmaRF/Settings.lua b/OmaRF/Settings.lua index ef6d46b..10cad7d 100644 --- a/OmaRF/Settings.lua +++ b/OmaRF/Settings.lua @@ -20,15 +20,8 @@ local charDefaults = { local chars = { ["Stormreaver"] = { ["Vildan"] = { - Positions = {"TOPRIGHT", "BOTTOMLEFT"}, AnchorX = 0, AnchorY = -330, - WatchedAuras = { - [53563] = "TOPRIGHT", - [156910] = "TOPRIGHT", - [200025] = "TOPRIGHT", - [200654] = "BOTTOMLEFT", - }, Clickheal = { ["type1"] = "spell", ["type2"] = "spell", @@ -49,13 +42,8 @@ local chars = { }, }, ["Gedren"] = { - Positions = {"TOPLEFT", "TOPRIGHT", "BOTTOMLEFT"}, AnchorX = 0, AnchorY = -330, - WatchedAuras = { - ["Rejuvenation"] = "TOPRIGHT", - ["Lifebloom"] = "TOPLEFT", - }, Clickheal = { ["type1"] = "spell", ["type2"] = "spell", diff --git a/OmaRF/images/square.tga b/OmaRF/images/square.tga new file mode 100644 index 0000000..3684ed6 Binary files /dev/null and b/OmaRF/images/square.tga differ