diff --git a/SVUI_!Core/system/api.lua b/SVUI_!Core/system/api.lua index ce6bb69..4527bfc 100644 --- a/SVUI_!Core/system/api.lua +++ b/SVUI_!Core/system/api.lua @@ -1,7 +1,7 @@ --[[ ########################################################## S V U I By: Munglunch -########################################################## +########################################################## LOCALIZED LUA FUNCTIONS ########################################################## ]]-- @@ -51,8 +51,8 @@ local GetCVarBool = _G.GetCVarBool; local SquareButton_SetIcon = _G.SquareButton_SetIcon; local RAID_CLASS_COLORS = _G.RAID_CLASS_COLORS; local CUSTOM_CLASS_COLORS = _G.CUSTOM_CLASS_COLORS; ---[[ -########################################################## +--[[ +########################################################## GET ADDON DATA ########################################################## ]]-- @@ -60,8 +60,8 @@ local SV = select(2, ...) local L = SV.L; local SVUILib = Librarian("Registry"); local MOD = SV:NewPackage("API", L["API"]); ---[[ -########################################################## +--[[ +########################################################## LOCALS ########################################################## ]]-- @@ -69,8 +69,8 @@ local MAC_DISPLAY; local BASE_MOD = 0.64; local SCREEN_MOD = 1; local LIVE_UPDATE_FRAMES = {}; ---[[ -########################################################## +--[[ +########################################################## LOOKUP TABLE ########################################################## ]]-- @@ -99,8 +99,8 @@ MOD.Templates = { }; MOD.Methods = {}; MOD.Concepts = {}; ---[[ -########################################################## +--[[ +########################################################## UI SCALING ########################################################## ]]-- @@ -115,17 +115,17 @@ local function ScreenUpdate() if(IsMacClient()) then if(not MAC_DISPLAY) then MAC_DISPLAY = SVUILib:NewGlobal("Display"); - if(not MAC_DISPLAY.Y or (MAC_DISPLAY.Y and type(MAC_DISPLAY.Y) ~= "number")) then + if(not MAC_DISPLAY.Y or (MAC_DISPLAY.Y and type(MAC_DISPLAY.Y) ~= "number")) then MAC_DISPLAY.Y = gxHeight; end - if(not MAC_DISPLAY.X or (MAC_DISPLAY.X and type(MAC_DISPLAY.X) ~= "number")) then + if(not MAC_DISPLAY.X or (MAC_DISPLAY.X and type(MAC_DISPLAY.X) ~= "number")) then MAC_DISPLAY.X = gxWidth; end end if(MAC_DISPLAY and MAC_DISPLAY.Y and MAC_DISPLAY.X) then - if(gxHeight ~= MAC_DISPLAY.Y or gxWidth ~= MAC_DISPLAY.X) then + if(gxHeight ~= MAC_DISPLAY.Y or gxWidth ~= MAC_DISPLAY.X) then gxHeight = MAC_DISPLAY.Y; - gxWidth = MAC_DISPLAY.X; + gxWidth = MAC_DISPLAY.X; end end end @@ -138,7 +138,7 @@ local function ScreenUpdate() if(type(ADJUSTED_SCALE) ~= "number") then ADJUSTED_SCALE = tonumber(ADJUSTED_SCALE); end - if(ADJUSTED_SCALE and ADJUSTED_SCALE ~= BASE_MOD) then + if(ADJUSTED_SCALE and ADJUSTED_SCALE ~= BASE_MOD) then BASE_MOD = ADJUSTED_SCALE; customScale = true; end @@ -158,8 +158,8 @@ local function ScreenUpdate() return gxWidth, gxHeight, gxScale, customScale end ---[[ -########################################################## +--[[ +########################################################## APPENDED POSITIONING METHODS ########################################################## ]]-- @@ -192,12 +192,12 @@ local WrapPoints = function(self, parent, x, y) local nx = _scale(x); local ny = _scale(y); parent = parent or self:GetParent() - if self:GetPoint() then + if self:GetPoint() then self:ClearAllPoints() - end + end self:SetPoint("TOPLEFT", parent, "TOPLEFT", -nx, ny) self:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", nx, -ny) -end +end local InsetPoints = function(self, parent, x, y) x = type(x) == "number" and x or 1 @@ -205,9 +205,9 @@ local InsetPoints = function(self, parent, x, y) local nx = _scale(x); local ny = _scale(y); parent = parent or self:GetParent() - if self:GetPoint() then + if self:GetPoint() then self:ClearAllPoints() - end + end self:SetPoint("TOPLEFT", parent, "TOPLEFT", nx, -ny) self:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", -nx, ny) end @@ -215,14 +215,14 @@ end local ModPoint= function(self, ...) for i = 1, select('#', ...) do local arg = select(i, ...) - if(arg and type(arg) == "number") then + if(arg and type(arg) == "number") then arg = _scale(arg) - end - end + end + end self:SetPoint(...) end ---[[ -########################################################## +--[[ +########################################################## APPENDED DESTROY METHODS ########################################################## ]]-- @@ -230,10 +230,10 @@ local _purgatory = CreateFrame("Frame", nil) _purgatory:Hide() local Die = function(self) - if(self.UnregisterAllEvents) then + if(self.UnregisterAllEvents) then self:UnregisterAllEvents() self:SetParent(_purgatory) - else + else self:Hide() self.Show = SV.fubar end @@ -242,7 +242,7 @@ end local RemoveTextures = function(self, option) if(self.Panel or (not self.GetNumRegions)) then return end local region, layer, texture - for i = 1, self:GetNumRegions()do + for i = 1, self:GetNumRegions()do region = select(i, self:GetRegions()) if(region and (region:GetObjectType() == "Texture")) then @@ -250,25 +250,25 @@ local RemoveTextures = function(self, option) texture = region:GetTexture() if(option) then - if(type(option) == "boolean") then - if region.UnregisterAllEvents then + if(type(option) == "boolean") then + if region.UnregisterAllEvents then region:UnregisterAllEvents() region:SetParent(_purgatory) - else - region.Show = region.Hide - end + else + region.Show = region.Hide + end region:Hide() elseif(type(option) == "string" and ((layer == option) or (texture ~= option))) then region:SetTexture("") end - else + else region:SetTexture("") end - end + end end -end ---[[ -########################################################## +end +--[[ +########################################################## SECURE FADING ########################################################## ]]-- @@ -310,20 +310,20 @@ local SecureFade_OnUpdate = function(self, elasped) if(frame) then local state = frame.___fadeset; state[4] = (state[4] or 0) + elasped; - if(state[4] < state[3]) then + if(state[4] < state[3]) then - if(frame.___fademode == "IN") then + if(frame.___fademode == "IN") then frame:SetAlpha((state[4] / state[3]) * (state[2] - state[1]) + state[1]) - elseif(frame.___fademode == "OUT") then + elseif(frame.___fademode == "OUT") then frame:SetAlpha(((state[3] - state[4]) / state[3]) * (state[1] - state[2]) + state[2]) - end + end else state[4] = 0 frame:SetAlpha(state[2]) local canfade = (not InCombatLockdown()) or (InCombatLockdown() and (not frame:IsProtected())) if(frame.___fadehide) then - if(canfade) then + if(canfade) then frame:Hide() if(frame.___fadefunc) then local _, catch = pcall(frame.___fadefunc, frame) @@ -358,7 +358,7 @@ local SecureFadeIn = function(self, duration, alphaStart, alphaEnd) local canfade = (not InCombatLockdown()) or (InCombatLockdown() and (not self:IsProtected())) if((not self:IsShown()) and canfade) then - self:Show() + self:Show() end if((not self:IsShown()) and (not canfade)) then @@ -366,7 +366,7 @@ local SecureFadeIn = function(self, duration, alphaStart, alphaEnd) end if(self:IsShown() and self:GetAlpha() == alpha2) then return end - if(not self.___fadehandler) then + if(not self.___fadehandler) then self.___fadehandler = CreateFrame("Frame", nil) self.___fadehandler.owner = self; end @@ -392,7 +392,7 @@ local SecureFadeIn = function(self, duration, alphaStart, alphaEnd) self.___fadehandler.Running = true; self.___fadehandler:SetScript("OnUpdate", SecureFade_OnUpdate) end -end +end local SecureFadeOut = function(self, duration, alphaStart, alphaEnd, hideOnFinished) local alpha1 = alphaStart or 1; @@ -400,7 +400,7 @@ local SecureFadeOut = function(self, duration, alphaStart, alphaEnd, hideOnFinis local timer = duration or 0.1; if(not self:IsShown() or self:GetAlpha() == alpha2) then return end - if(not self.___fadehandler) then + if(not self.___fadehandler) then self.___fadehandler = CreateFrame("Frame", nil) self.___fadehandler.owner = self; end @@ -438,47 +438,47 @@ local SecureFadeCallback = function(self, callback, onForceHide, onForceShow) self.___fadefunc = callback; end end ---[[ -########################################################## +--[[ +########################################################## TEMPLATE INTERNAL HANDLERS ########################################################## ]]-- local HookPanelBorderColor = function(self,r,g,b,a) - if self.BorderLeft then + if self.BorderLeft then self.BorderLeft:SetVertexColor(r,g,b,a) self.BorderRight:SetVertexColor(r,g,b,a) self.BorderTop:SetVertexColor(r,g,b,a) - self.BorderBottom:SetVertexColor(r,g,b,a) + self.BorderBottom:SetVertexColor(r,g,b,a) end if self.Shadow then local alpha = self.Shadow:GetAttribute("shadowAlpha") or 0.5 self.Shadow:SetBackdropBorderColor(r,g,b,alpha) - end -end + end +end local HookBackdrop = function(self,...) if(self.Panel) then self.Panel:SetBackdrop(...) end -end +end -local HookBackdropColor = function(self,...) +local HookBackdropColor = function(self,...) if(self.Panel) then self.Panel:SetBackdropColor(...) end -end +end local HookBackdropBorderColor = function(self,...) if(self.Panel) then self.Panel:SetBackdropBorderColor(...) end -end +end -local HookVertexColor = function(self,...) +local HookVertexColor = function(self,...) if(self.Panel) then self.Panel.Skin:SetVertexColor(...) end -end +end local HookCustomBackdrop = function(self) if(self.Panel) then @@ -506,18 +506,18 @@ local HookCustomBackdrop = function(self) local edgeSize = self.Panel:GetAttribute("panelPadding") or 1 local offset = ceil(edgeSize * 0.25) self.Panel:SetBackdrop({ - bgFile = newBgFile, - edgeFile = newBorderFile, - tile = true, - tileSize = sizeMod, - edgeSize = edgeSize, - insets = + bgFile = newBgFile, + edgeFile = newBorderFile, + tile = true, + tileSize = sizeMod, + edgeSize = edgeSize, + insets = { - left = offset, - right = offset, - top = offset, - bottom = offset, - }, + left = offset, + right = offset, + top = offset, + bottom = offset, + }, }) self.Panel:SetBackdropBorderColor(0,0,0,1) if(edgeSize and edgeSize > 0 and (not self.Panel:GetAttribute("panelLocked"))) then @@ -549,35 +549,35 @@ end local Cooldown_ForceUpdate = function(self) self.nextUpdate = 0; self:Show() -end +end local Cooldown_StopTimer = function(self) self.enable = nil; self:Hide() -end +end local Cooldown_OnUpdate = function(self, elapsed) - if self.nextUpdate > 0 then + if self.nextUpdate > 0 then self.nextUpdate = self.nextUpdate - elapsed; - return + return end local now = GetTime(); local start = self.start; local remaining = now - start; local expires = (self.duration - remaining); - if expires > 0.05 then - if (self.fontScale * self:GetEffectiveScale() / UIParent:GetScale()) < 0.5 then + if expires > 0.05 then + if (self.fontScale * self:GetEffectiveScale() / UIParent:GetScale()) < 0.5 then self.text:SetText('') - self.nextUpdate = 500 - else + self.nextUpdate = 500 + else local timeLeft = 0; local calc = 0; if expires < 4 then self.nextUpdate = 0.051 self.text:SetFormattedText("|cffff0000%.1f|r", expires) - elseif expires < 60 then + elseif expires < 60 then self.nextUpdate = 0.51 - self.text:SetFormattedText("|cffffff00%d|r", floor(expires)) + self.text:SetFormattedText("|cffffff00%d|r", floor(expires)) elseif expires < 3600 then timeLeft = ceil(expires / 60); calc = floor((expires / 60) + .5); @@ -599,9 +599,9 @@ local Cooldown_OnUpdate = function(self, elapsed) end end end - else + else Cooldown_StopTimer(self) - end + end end local Cooldown_OnSizeChanged = function(self, width, height) @@ -610,20 +610,20 @@ local Cooldown_OnSizeChanged = function(self, width, height) local newSize = floor(width + .5) / 36; override = override or frame:GetParent():GetParent().SizeOverride; if override then - newSize = override / 20 - end - if newSize == frame.fontScale then - return - end + newSize = override / 20 + end + if newSize == frame.fontScale then + return + end frame.fontScale = newSize; - if newSize < 0.5 and not override then + if newSize < 0.5 and not override then frame:Hide() - else + else frame:Show() frame.text:SetFont(SV.media.font.number, newSize * 15, 'OUTLINE') if frame.enable then Cooldown_ForceUpdate(frame) - end + end end end @@ -644,34 +644,34 @@ local CreateCooldownTimer = function(self) local width, height = self:GetSize() Cooldown_OnSizeChanged(self, width, height) self:SetScript('OnSizeChanged', Cooldown_OnSizeChanged) - - return self.timer + + return self.timer end local _hook_Cooldown_SetCooldown = function(self, start, duration, elapsed) - if start > 0 and duration > 2.5 then + if start > 0 and duration > 2.5 then local timer = self.timer or CreateCooldownTimer(self) timer.start = start; timer.duration = duration; timer.enable = true; timer.nextUpdate = 0; - - if timer.fontScale >= 0.5 then + + if timer.fontScale >= 0.5 then timer:Show() - end - else + end + else local timer = self.timer; - if timer then + if timer then Cooldown_StopTimer(timer) - end - end - if self.timer then - if elapsed and elapsed > 0 then + end + end + if self.timer then + if elapsed and elapsed > 0 then self.timer:SetAlpha(0) else self.timer:SetAlpha(0.8) - end - end + end + end end local SetFrameBorderColor = function(self, r, g, b, setPrevious, reset) @@ -692,21 +692,12 @@ local HideAlertFlash = function(self) SV.Animate:StopFlash(self.Panel.Shadow) self:ColorBorder(1,0.9,0, nil, true) end ---[[ -########################################################## +--[[ +########################################################## TEMPLATE HELPERS ########################################################## ]]-- -function MOD:FLASH(frame) - if(frame.Panel.Shadow) then - frame.Panel.__previous = 'darkest'; - frame.ColorBorder = SetFrameBorderColor - frame.StartAlert = ShowAlertFlash - frame.StopAlert = HideAlertFlash - end -end - -function MOD:CD(button, noSwipe) +local function SetCD(button, noSwipe) local bn = button:GetName() if(bn) then local cooldown = _G[bn.."Cooldown"]; @@ -725,7 +716,37 @@ function MOD:CD(button, noSwipe) cooldown.HookedCooldown = true end end + return cooldown end + return false +end + +function MOD:FLASH(frame) + if(frame.Panel.Shadow) then + frame.Panel.__previous = 'darkest'; + frame.ColorBorder = SetFrameBorderColor + frame.StartAlert = ShowAlertFlash + frame.StopAlert = HideAlertFlash + end +end + +function MOD:CD(frame, noSwipe) + local cooldown = SetCD(frame, noSwipe) + if(not cooldown) then + cooldown = CreateFrame("Cooldown", nil, frame) + cooldown:ClearAllPoints() + cooldown:InsetPoints(frame, 1, 1) + cooldown:SetDrawEdge(false) + cooldown:SetDrawBling(false) + if(not noSwipe) then + cooldown:SetSwipeColor(0, 0, 0, 1) + end + if(not cooldown.HookedCooldown) then + hooksecurefunc(cooldown, "SetCooldown", _hook_Cooldown_SetCooldown) + cooldown.HookedCooldown = true + end + end + return cooldown end function MOD:APPLY(frame, templateName, underlay, padding, xOffset, yOffset, defaultColor) @@ -774,8 +795,8 @@ function MOD:APPLY(frame, templateName, underlay, padding, xOffset, yOffset, def --panel:WrapPoints(frame, xOffset, yOffset) panel:SetPoint("TOPLEFT", frame, "TOPLEFT", -xOffset, yOffset) panel:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", xOffset, -yOffset) - - if(padding and panel.BorderLeft) then + + if(padding and panel.BorderLeft) then panel.BorderLeft:SetWidth(padding) panel.BorderRight:SetWidth(padding) panel.BorderTop:SetHeight(padding) @@ -791,9 +812,9 @@ function MOD:APPLY(frame, templateName, underlay, padding, xOffset, yOffset, def panel.Shadow:SetBackdropBorderColor(0,0,0,alpha) local level = panel.Shadow:GetFrameLevel() - 1 - if(level >= 0) then + if(level >= 0) then panel.Shadow:SetFrameLevel(level) - else + else panel.Shadow:SetFrameLevel(0) end end @@ -836,7 +857,7 @@ function MOD:APPLY(frame, templateName, underlay, padding, xOffset, yOffset, def end if(gradientName and SV.media.gradient[gradientName]) then panel.Skin:SetGradient(unpack(SV.media.gradient[gradientName])) - else + else panel.Skin:SetVertexColor(bgColor[1], bgColor[2], bgColor[3], bgColor[4] or 1) end @@ -856,33 +877,33 @@ function MOD:APPLY(frame, templateName, underlay, padding, xOffset, yOffset, def frame.Panel = panel; end ---[[ -########################################################## +--[[ +########################################################## UI ELEMENT METHODS ########################################################## ]]-- local function CommonButtonSettings(frame, addChecked, noSwipe) - if(frame.Left) then + if(frame.Left) then frame.Left:SetAlpha(0) - end + end - if(frame.Middle) then + if(frame.Middle) then frame.Middle:SetAlpha(0) - end + end - if(frame.Right) then + if(frame.Right) then frame.Right:SetAlpha(0) - end + end - if(frame.SetNormalTexture) then + if(frame.SetNormalTexture) then frame:SetNormalTexture("") - end + end - if(frame.SetDisabledTexture) then + if(frame.SetDisabledTexture) then frame:SetDisabledTexture("") end - if(frame.SetCheckedTexture) then + if(frame.SetCheckedTexture) then frame:SetCheckedTexture("") end @@ -893,11 +914,11 @@ local function CommonButtonSettings(frame, addChecked, noSwipe) frame.hover = hover; end frame.hover:SetTexture(0.1, 0.8, 0.8, 0.5) - frame:SetHighlightTexture(frame.hover) + frame:SetHighlightTexture(frame.hover) end if(frame.SetPushedTexture) then - if(not frame.pushed) then + if(not frame.pushed) then local pushed = frame:CreateTexture(nil, "OVERLAY") pushed:InsetPoints(frame.Panel) frame.pushed = pushed; @@ -917,7 +938,7 @@ local function CommonButtonSettings(frame, addChecked, noSwipe) frame:SetCheckedTexture(frame.checked) end - MOD:CD(frame, noSwipe) + SetCD(frame, noSwipe) end MOD.Methods["Button"] = function(self, frame, inverse, xOffset, yOffset, defaultColor) @@ -975,9 +996,9 @@ MOD.Methods["Checkbox"] = function(self, frame, inverse, x, y) local underlay = (not inverse) self:APPLY(frame, "Checkbox", inverse, 1, 1, 1) - if(frame.SetNormalTexture) then + if(frame.SetNormalTexture) then frame:SetNormalTexture("") - end + end if(frame.SetPushedTexture) then frame:SetPushedTexture("") @@ -991,7 +1012,7 @@ MOD.Methods["Checkbox"] = function(self, frame, inverse, x, y) end local color = SV.media.color.highlight frame.hover:SetTexture(color[1], color[2], color[3], 0.5) - frame:SetHighlightTexture(frame.hover) + frame:SetHighlightTexture(frame.hover) end if(frame.SetCheckedTexture) then @@ -1010,27 +1031,27 @@ end; MOD.Methods["Editbox"] = function(self, frame, inverse, x, y) if(not frame or (frame and frame.Panel)) then return end - if frame.TopLeftTex then frame.TopLeftTex:Die() end - if frame.TopRightTex then frame.TopRightTex:Die() end - if frame.TopTex then frame.TopTex:Die() end - if frame.BottomLeftTex then frame.BottomLeftTex:Die() end - if frame.BottomRightTex then frame.BottomRightTex:Die() end - if frame.BottomTex then frame.BottomTex:Die() end - if frame.LeftTex then frame.LeftTex:Die() end - if frame.RightTex then frame.RightTex:Die() end + if frame.TopLeftTex then frame.TopLeftTex:Die() end + if frame.TopRightTex then frame.TopRightTex:Die() end + if frame.TopTex then frame.TopTex:Die() end + if frame.BottomLeftTex then frame.BottomLeftTex:Die() end + if frame.BottomRightTex then frame.BottomRightTex:Die() end + if frame.BottomTex then frame.BottomTex:Die() end + if frame.LeftTex then frame.LeftTex:Die() end + if frame.RightTex then frame.RightTex:Die() end if frame.MiddleTex then frame.MiddleTex:Die() end - if frame.Left then frame.Left:Die() end - if frame.Right then frame.Right:Die() end + if frame.Left then frame.Left:Die() end + if frame.Right then frame.Right:Die() end if frame.Middle then frame.Middle:Die() end local underlay = (not inverse) self:APPLY(frame, "Inset", underlay, 1, x, y) local globalName = frame:GetName(); - if globalName then - if _G[globalName.."Left"] then _G[globalName.."Left"]:Die() end - if _G[globalName.."Middle"] then _G[globalName.."Middle"]:Die() end - if _G[globalName.."Right"] then _G[globalName.."Right"]:Die() end + if globalName then + if _G[globalName.."Left"] then _G[globalName.."Left"]:Die() end + if _G[globalName.."Middle"] then _G[globalName.."Middle"]:Die() end + if _G[globalName.."Right"] then _G[globalName.."Right"]:Die() end if _G[globalName.."Mid"] then _G[globalName.."Mid"]:Die() end if globalName:find("Silver") or globalName:find("Copper") or globalName:find("Gold") then @@ -1038,13 +1059,13 @@ MOD.Methods["Editbox"] = function(self, frame, inverse, x, y) if globalName:find("Silver") or globalName:find("Copper") then frame.Panel:SetPoint("BOTTOMRIGHT", -12, -2) else - frame.Panel:SetPoint("BOTTOMRIGHT", -2, -2) - end - end + frame.Panel:SetPoint("BOTTOMRIGHT", -2, -2) + end + end end end; ---[[ -########################################################## +--[[ +########################################################## CUSTOM TEMPLATING METHODS ########################################################## ]]-- @@ -1060,27 +1081,27 @@ MOD.Methods["DockButton"] = function(self, frame, inverse) self:APPLY(frame, "DockButton", inverse) self:FLASH(frame) - if(frame.Left) then + if(frame.Left) then frame.Left:SetAlpha(0) - end + end - if(frame.Middle) then + if(frame.Middle) then frame.Middle:SetAlpha(0) - end + end - if(frame.Right) then + if(frame.Right) then frame.Right:SetAlpha(0) - end + end - if(frame.SetNormalTexture) then + if(frame.SetNormalTexture) then frame:SetNormalTexture("") - end + end - if(frame.SetDisabledTexture) then + if(frame.SetDisabledTexture) then frame:SetDisabledTexture("") end - if(frame.SetCheckedTexture) then + if(frame.SetCheckedTexture) then frame:SetCheckedTexture("") end @@ -1091,7 +1112,7 @@ MOD.Methods["DockButton"] = function(self, frame, inverse) frame.hover = hover; end frame.hover:SetTexture(0.1, 0.8, 0.8, 0.5) - frame:SetHighlightTexture(frame.hover) + frame:SetHighlightTexture(frame.hover) end if(not frame.Panel:GetAttribute("panelSkipUpdate")) then @@ -1115,14 +1136,14 @@ MOD.Methods["Frame"] = function(self, frame, inverse, styleName, noupdate, overr tinsert(LIVE_UPDATE_FRAMES, frame); end end; ---[[ -########################################################## +--[[ +########################################################## TEMPLATE API ########################################################## ]]-- local SetPanelColor = function(self, ...) local arg1,arg2,arg3,arg4,arg5,arg6,arg7 = select(1, ...) - if(not self.Panel or not arg1) then return; end + if(not self.Panel or not arg1) then return; end if(self.Panel.Skin and self.Panel:GetAttribute("panelGradient")) then if(type(arg1) == "string") then if(arg1 == "VERTICAL" or arg1 == "HORIZONTAL") then @@ -1133,14 +1154,14 @@ local SetPanelColor = function(self, ...) local t = SV.media.color[arg1] self:SetBackdropColor(t[1], t[2], t[3], t[4]) end - end - end + end + end elseif(type(arg1) == "string" and SV.media.color[arg1]) then local t = SV.media.color[arg1] self:SetBackdropColor(t[1], t[2], t[3], t[4]) elseif(arg1 and type(arg1) == "number") then self:SetBackdropColor(...) - end + end end local SetStyle = function(self, method, ...) @@ -1160,8 +1181,8 @@ local SetStyle = function(self, method, ...) end end end ---[[ -########################################################## +--[[ +########################################################## HOOKED ATLAS HIJACKER ########################################################## ]]-- @@ -1184,8 +1205,8 @@ local StealAtlas = function(self, atlas) end end end ---[[ -########################################################## +--[[ +########################################################## UPDATE CALLBACKS ########################################################## ]]-- @@ -1215,7 +1236,7 @@ local function FrameTemplateUpdates() if(tex) then frame.Panel.Skin:SetTexture(tex) --if(panelID == 'unitlarge') then print(frame.Panel.Skin:GetTexture()) end - end + end if(not frame.NoColorUpdate) then local gradient = frame.Panel:GetAttribute("panelGradient") if(gradient and SV.media.gradient[gradient]) then @@ -1232,8 +1253,8 @@ end SV.Events:On("SHARED_MEDIA_UPDATED", FrameTemplateUpdates, true); SV.Events:On("REQUEST_TEMPLATE_UPDATED", FrameTemplateUpdates, true); ---[[ -########################################################## +--[[ +########################################################## CORE FUNCTIONS ########################################################## ]]-- @@ -1268,42 +1289,42 @@ function SV:UI_SCALE_CHANGED(event) self.LowRez = nil local evalwidth; if(self.db.screen.multiMonitor) then - if(gxWidth < 4080) then + if(gxWidth < 4080) then evalwidth = 1224; - elseif(gxWidth < 4320) then + elseif(gxWidth < 4320) then evalwidth = 1360; - elseif(gxWidth < 4680) then + elseif(gxWidth < 4680) then evalwidth = 1400; - elseif(gxWidth < 4800) then + elseif(gxWidth < 4800) then evalwidth = 1440; - elseif(gxWidth < 5760) then - if(gxHeight == 900) then evalwidth = 1600 else evalwidth = 1680 end - elseif(gxWidth < 7680) then + elseif(gxWidth < 5760) then + if(gxHeight == 900) then evalwidth = 1600 else evalwidth = 1680 end + elseif(gxWidth < 7680) then evalwidth = 1920; - elseif(gxWidth < 9840) then + elseif(gxWidth < 9840) then evalwidth = 2560; - elseif(gxWidth > 9839) then - evalwidth = 3280; + elseif(gxWidth > 9839) then + evalwidth = 3280; end else - if(gxWidth < 4080) then + if(gxWidth < 4080) then evalwidth = 3840; - elseif(gxWidth < 4320) then + elseif(gxWidth < 4320) then evalwidth = 4080; - elseif(gxWidth < 4680) then + elseif(gxWidth < 4680) then evalwidth = 4320; - elseif(gxWidth < 4800) then + elseif(gxWidth < 4800) then evalwidth = 4680; - elseif(gxWidth < 5040) then - evalwidth = 4800; - elseif(gxWidth < 5760) then - evalwidth = 5040; - elseif(gxWidth < 7680) then + elseif(gxWidth < 5040) then + evalwidth = 4800; + elseif(gxWidth < 5760) then + evalwidth = 5040; + elseif(gxWidth < 7680) then evalwidth = 5760; - elseif(gxWidth < 9840) then + elseif(gxWidth < 9840) then evalwidth = 7680; - elseif(gxWidth > 9839) then - evalwidth = 9840; + elseif(gxWidth > 9839) then + evalwidth = 9840; end end @@ -1316,7 +1337,7 @@ function SV:UI_SCALE_CHANGED(event) local testScale2 = parsefloat(gxScale, 5) local ignoreChange = false; - if(event == "PLAYER_LOGIN" and (testScale1 ~= testScale2)) then + if(event == "PLAYER_LOGIN" and (testScale1 ~= testScale2)) then SetCVar("useUiScale", 1) SetCVar("uiScale", gxScale) WorldMapFrame.hasTaint = true; @@ -1351,8 +1372,8 @@ function SV:UI_SCALE_CHANGED(event) end end end ---[[ -########################################################## +--[[ +########################################################## API INJECTION ########################################################## ]]-- @@ -1413,8 +1434,8 @@ while CURRENT_OBJECT do AppendFrameMethods(CURRENT_OBJECT) CURRENT_OBJECT = EnumerateFrames(CURRENT_OBJECT) end ---[[ -########################################################## +--[[ +########################################################## STYLING CONCEPTS ########################################################## ]]-- @@ -1458,7 +1479,7 @@ MOD.Concepts["Frame"] = function(self, adjustable, frame, template, noStripping, if(not frame or (frame and frame.Panel)) then return end template = template or "Transparent" local baselevel = frame:GetFrameLevel() - if(baselevel < 1) then + if(baselevel < 1) then frame:SetFrameLevel(1) end if(not noStripping) then @@ -1471,7 +1492,7 @@ MOD.Concepts["Window"] = function(self, adjustable, frame, altStyle, fullStrip, if(not frame or (frame and frame.Panel)) then return end local template = altStyle and "Window2" or "Window" local baselevel = frame:GetFrameLevel() - if(baselevel < 1) then + if(baselevel < 1) then frame:SetFrameLevel(1) end RemoveTextures(frame, fullStrip) @@ -1485,7 +1506,7 @@ end MOD.Concepts["CloseButton"] = function(self, adjustable, frame, targetAnchor) if(not frame or (frame and frame.Panel)) then return end - + RemoveTextures(frame) self.Methods["Button"](self, frame, adjustable, -6, -6, "red") @@ -1496,13 +1517,13 @@ MOD.Concepts["CloseButton"] = function(self, adjustable, frame, targetAnchor) if(targetAnchor) then frame:ClearAllPoints() - frame:SetPoint("TOPRIGHT", targetAnchor, "TOPRIGHT", 3, 3) + frame:SetPoint("TOPRIGHT", targetAnchor, "TOPRIGHT", 3, 3) end end MOD.Concepts["InfoButton"] = function(self, adjustable, frame, targetAnchor, size) if(not frame or (frame and frame.Panel)) then return end - + RemoveTextures(frame) size = size or 26 frame:SetSize(size, size) @@ -1513,7 +1534,7 @@ MOD.Concepts["InfoButton"] = function(self, adjustable, frame, targetAnchor, siz if(targetAnchor) then frame:ClearAllPoints() - frame:SetPoint("TOPRIGHT", targetAnchor, "TOPRIGHT", 3, 3) + frame:SetPoint("TOPRIGHT", targetAnchor, "TOPRIGHT", 3, 3) end end @@ -1531,12 +1552,12 @@ MOD.Concepts["ArrowButton"] = function(self, adjustable, frame, direction, targe if(targetAnchor) then frame:ClearAllPoints() - frame:SetPoint("TOPRIGHT", targetAnchor, "TOPRIGHT", 0, 0) + frame:SetPoint("TOPRIGHT", targetAnchor, "TOPRIGHT", 0, 0) end end MOD.Concepts["ItemButton"] = function(self, adjustable, frame, noScript) - if(not frame) then return end + if(not frame) then return end RemoveTextures(frame) @@ -1570,12 +1591,12 @@ MOD.Concepts["ItemButton"] = function(self, adjustable, frame, noScript) frame.Riser = fg end - if(iconObject) then + if(iconObject) then iconObject:SetTexCoord(unpack(_G.SVUI_ICON_COORDS)) - if(not adjustable) then + if(not adjustable) then iconObject:InsetPoints(frame, 2, 2) - end + end if(not frame.IconShadow) then frame.IconShadow = CreateFrame("Frame", nil, frame) frame.IconShadow:WrapPoints(iconObject) @@ -1597,7 +1618,7 @@ MOD.Concepts["ItemButton"] = function(self, adjustable, frame, noScript) if(subNameObject) then subNameObject:SetParent(frame.Riser) end if(arrowObject) then arrowObject:SetParent(frame.Riser) end - if(levelObject) then + if(levelObject) then levelObject:SetParent(frame.Riser) levelObject:SetFontObject(SVUI_Font_Number) levelObject:SetDrawLayer("ARTWORK", 7) @@ -1606,7 +1627,7 @@ MOD.Concepts["ItemButton"] = function(self, adjustable, frame, noScript) end MOD.Concepts["PageButton"] = function(self, adjustable, frame, isVertical, isLeft) - if((not frame) or (frame.Panel)) then return end + if((not frame) or (frame.Panel)) then return end local bName = frame:GetName() local leftDown; @@ -1614,7 +1635,7 @@ MOD.Concepts["PageButton"] = function(self, adjustable, frame, isVertical, isLef local testName = bName:lower() leftDown = ((bName and testName:find('left')) or testName:find('prev') or testName:find('decrement')) or false else - leftDown = isLeft or false + leftDown = isLeft or false end RemoveTextures(frame) @@ -1626,7 +1647,7 @@ MOD.Concepts["PageButton"] = function(self, adjustable, frame, isVertical, isLef self.Methods["Button"](self, frame, adjustable, -4, -4) - if not frame.icon then + if not frame.icon then frame.icon = frame:CreateTexture(nil,'ARTWORK') frame.icon:ModSize(13) frame.icon:SetPoint('CENTER') @@ -1634,9 +1655,9 @@ MOD.Concepts["PageButton"] = function(self, adjustable, frame, isVertical, isLef frame.icon:SetTexCoord(0.02, 0.2, 0.02, 0.2) frame:SetScript('OnMouseDown',function(self) - if self:IsEnabled() then + if self:IsEnabled() then self.icon:SetPoint("CENTER",-1,-1) - end + end end) frame:SetScript('OnMouseUp',function(self) @@ -1653,38 +1674,38 @@ MOD.Concepts["PageButton"] = function(self, adjustable, frame, isVertical, isLef self.icon:SetAlpha(1.0) end) - if not frame:IsEnabled() then + if not frame:IsEnabled() then frame:GetScript('OnDisable')(frame) - end + end end - if isVertical then - if leftDown then SquareButton_SetIcon(frame,'UP') else SquareButton_SetIcon(frame,'DOWN')end - else - if leftDown then SquareButton_SetIcon(frame,'LEFT') else SquareButton_SetIcon(frame,'RIGHT')end + if isVertical then + if leftDown then SquareButton_SetIcon(frame,'UP') else SquareButton_SetIcon(frame,'DOWN')end + else + if leftDown then SquareButton_SetIcon(frame,'LEFT') else SquareButton_SetIcon(frame,'RIGHT')end end end MOD.Concepts["ScrollFrame"] = function(self, adjustable, frame, scale, yOffset) - if(not frame or (frame and frame.Panel)) then return end + if(not frame or (frame and frame.Panel)) then return end scale = scale or 5 local scrollName = frame:GetName() local bg, track, top, bottom, mid, upButton, downButton bg = _G[("%sBG"):format(scrollName)] - if(bg) then bg:SetTexture("") end + if(bg) then bg:SetTexture("") end track = _G[("%sTrack"):format(scrollName)] - if(track) then track:SetTexture("") end + if(track) then track:SetTexture("") end top = _G[("%sTop"):format(scrollName)] - if(top) then top:SetTexture("") end + if(top) then top:SetTexture("") end bottom = _G[("%sBottom"):format(scrollName)] - if(bottom) then bottom:SetTexture("") end + if(bottom) then bottom:SetTexture("") end mid = _G[("%sMiddle"):format(scrollName)] - if(mid) then mid:SetTexture("") end + if(mid) then mid:SetTexture("") end upButton = _G[("%sScrollUpButton"):format(scrollName)] downButton = _G[("%sScrollDownButton"):format(scrollName)] - if(upButton and downButton) then + if(upButton and downButton) then RemoveTextures(upButton) if(not upButton.icon) then local upW, upH = upButton:GetSize() @@ -1697,10 +1718,10 @@ MOD.Concepts["ScrollFrame"] = function(self, adjustable, frame, scale, yOffset) upButton:ClearAllPoints() upButton:SetPoint(anchor, parent, relative, xBase, yAdjust) end - end + end RemoveTextures(downButton) if(not downButton.icon) then - local dnW, dnH = downButton:GetSize() + local dnW, dnH = downButton:GetSize() self.Concepts["PageButton"](self, false, downButton) SquareButton_SetIcon(downButton, "DOWN") downButton:ModSize(dnW + scale, dnH + scale) @@ -1710,8 +1731,8 @@ MOD.Concepts["ScrollFrame"] = function(self, adjustable, frame, scale, yOffset) downButton:ClearAllPoints() downButton:SetPoint(anchor, parent, relative, xBase, yAdjust) end - end - if(not frame.BG) then + end + if(not frame.BG) then frame.BG = frame:CreateTexture(nil, "BACKGROUND") frame.BG:SetPoint("TOPLEFT", upButton, "TOPLEFT", 1, -1) frame.BG:SetPoint("BOTTOMRIGHT", downButton, "BOTTOMRIGHT", -1, 1) @@ -1722,8 +1743,8 @@ MOD.Concepts["ScrollFrame"] = function(self, adjustable, frame, scale, yOffset) fg:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -10, 6) fg:SetBackdrop(SV.media.backdrop.outline) frame.Brdr = fg - end - if(frame.SetThumbTexture) then + end + if(frame.SetThumbTexture) then frame:SetThumbTexture(SV.media.button.knob) end end @@ -1732,19 +1753,19 @@ end MOD.Concepts["ScrollBar"] = function(self, adjustable, frame) if(not frame or (frame and (not frame.GetOrientation or frame.Panel))) then return end - if(frame:GetOrientation() == "VERTICAL") then + if(frame:GetOrientation() == "VERTICAL") then frame:SetWidth(12) - else + else frame:SetHeight(12) - for i=1, frame:GetNumRegions() do + for i=1, frame:GetNumRegions() do local child = select(i, frame:GetRegions()) - if(child and child:GetObjectType() == "FontString") then + if(child and child:GetObjectType() == "FontString") then local anchor, parent, relative, x, y = child:GetPoint() - if relative:find("BOTTOM") then + if relative:find("BOTTOM") then child:SetPoint(anchor, parent, relative, x, y - 4) - end - end - end + end + end + end end RemoveTextures(frame) @@ -1755,7 +1776,7 @@ MOD.Concepts["ScrollBar"] = function(self, adjustable, frame) end MOD.Concepts["Tab"] = function(self, adjustable, frame, addBackground, xOffset, yOffset) - if(not frame or (frame and frame.Panel)) then return end + if(not frame or (frame and frame.Panel)) then return end local tab = frame:GetName(); @@ -1766,7 +1787,7 @@ MOD.Concepts["Tab"] = function(self, adjustable, frame, addBackground, xOffset, if _G[tab.."Middle"] then _G[tab.."Middle"]:SetTexture("") end if _G[tab.."MiddleDisabled"] then _G[tab.."MiddleDisabled"]:SetTexture("") end - if(frame.GetHighlightTexture and frame:GetHighlightTexture()) then + if(frame.GetHighlightTexture and frame:GetHighlightTexture()) then frame:GetHighlightTexture():SetTexture("") end @@ -1817,7 +1838,7 @@ MOD.Concepts["DropDown"] = function(self, adjustable, frame, width) local ddText = _G[("%sText"):format(ddName)] local ddButton = _G[("%sButton"):format(ddName)] - if not width then width = max(frame:GetWidth(), 128) end + if not width then width = max(frame:GetWidth(), 128) end RemoveTextures(frame) frame:SetWidth(width) @@ -1840,7 +1861,7 @@ MOD.Concepts["DropDown"] = function(self, adjustable, frame, width) currentLevel = 1 end - if(not frame.BG) then + if(not frame.BG) then frame.BG = frame:CreateTexture(nil, "BACKGROUND") frame.BG:SetPoint("TOPLEFT", frame, "TOPLEFT", 18, -2) frame.BG:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -10, 6) @@ -1851,18 +1872,18 @@ MOD.Concepts["DropDown"] = function(self, adjustable, frame, width) fg:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -10, 6) fg:SetBackdrop(SV.media.backdrop.outline) frame.Brdr = fg - end + end end -end +end MOD.Concepts["Tooltip"] = function(self, adjustable, frame, useHook) - if(not frame or (frame and frame.Panel)) then return end + if(not frame or (frame and frame.Panel)) then return end if frame.Background then frame.Background:SetTexture("") end - if frame.Delimiter1 then + if frame.Delimiter1 then frame.Delimiter1:SetTexture("") frame.Delimiter2:SetTexture("") end @@ -1898,7 +1919,7 @@ MOD.Concepts["Tooltip"] = function(self, adjustable, frame, useHook) if frame.BorderBottomLeft then frame.BorderBottomLeft:SetTexture("") end - + frame:SetBackdrop(SV.media.backdrop.tooltip) if(useHook) then @@ -1951,7 +1972,7 @@ MOD.Concepts["QuestItem"] = function(self, adjustable, frame) iconFallback:SetTexture([[Interface\ICONS\INV_Misc_Bag_10]]) iconFallback:SetTexCoord(unpack(_G.SVUI_ICON_COORDS)) - if(oldIcon) then + if(oldIcon) then icon:SetTexture(oldIcon) end icon:SetTexCoord(unpack(_G.SVUI_ICON_COORDS)) @@ -1964,7 +1985,7 @@ MOD.Concepts["Skin"] = function(self, style, frame, topX, topY, bottomX, bottomY local artname = style:lower() local texture = SV.media.background[artname] or SV.media.background.model RemoveTextures(frame, true) - + local borderFrame = CreateFrame("Frame", nil, frame) borderFrame:SetPoint("TOPLEFT", frame, "TOPLEFT", topX, topY) borderFrame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", bottomX, bottomY) @@ -1979,7 +2000,7 @@ end local ALERT_TEMPLATE = { ["typeA"] = { COLOR = {0.8, 0.2, 0.2}, - BG = [[Interface\AddOns\SVUI_!Core\assets\textures\Alert\ALERT-BG]], + BG = [[Interface\AddOns\SVUI_!Core\assets\textures\Alert\ALERT-BG]], LEFT = [[Interface\AddOns\SVUI_!Core\assets\textures\Alert\ALERT-LEFT]], RIGHT = [[Interface\AddOns\SVUI_!Core\assets\textures\Alert\ALERT-RIGHT]], TOP = [[Interface\AddOns\SVUI_!Core\assets\textures\Alert\ALERT-TOP]], @@ -1987,7 +2008,7 @@ local ALERT_TEMPLATE = { }, ["typeB"] = { COLOR = {0.08, 0.4, 0}, - BG = [[Interface\AddOns\SVUI_!Core\assets\textures\Alert\ALERT-BG-2]], + BG = [[Interface\AddOns\SVUI_!Core\assets\textures\Alert\ALERT-BG-2]], LEFT = [[Interface\AddOns\SVUI_!Core\assets\textures\Alert\ALERT-LEFT-2]], RIGHT = [[Interface\AddOns\SVUI_!Core\assets\textures\Alert\ALERT-RIGHT-2]], TOP = [[Interface\AddOns\SVUI_!Core\assets\textures\Alert\ALERT-TOP]], @@ -2125,4 +2146,4 @@ end -- print(globalName) -- end -- end --- end) \ No newline at end of file +-- end) diff --git a/SVUI_Auras/Loader.lua b/SVUI_Auras/Loader.lua index bb75d53..28269ed 100644 --- a/SVUI_Auras/Loader.lua +++ b/SVUI_Auras/Loader.lua @@ -1,7 +1,7 @@ --[[ ########################################################## S V U I By: Munglunch -########################################################## +########################################################## LOCALIZED LUA FUNCTIONS ########################################################## ]]-- @@ -36,151 +36,151 @@ SV.defaults[Schema] = { ["aurasEnabled"] = true, ["hyperBuffsEnabled"] = true, ["hyperBuffsFiltered"] = true, - ["font"] = "SVUI Number Font", - ["fontSize"] = 12, - ["fontOutline"] = "THINOUTLINE", - ["countOffsetV"] = 0, - ["countOffsetH"] = 0, - ["timeOffsetV"] = -4, - ["timeOffsetH"] = 0, + ["font"] = "SVUI Number Font", + ["fontSize"] = 12, + ["fontOutline"] = "THINOUTLINE", + ["countOffsetV"] = 0, + ["countOffsetH"] = 0, + ["timeOffsetV"] = -4, + ["timeOffsetH"] = 0, ["fadeBy"] = 5, - ["procsEnabled"] = false, - ["procSize"] = 40, + ["procsEnabled"] = true, + ["procSize"] = 40, ["buffs"] = { - ["showBy"] = "LEFT_DOWN", - ["wrapAfter"] = 12, - ["maxWraps"] = 3, - ["wrapXOffset"] = 6, - ["wrapYOffset"] = 16, - ["sortMethod"] = "TIME", - ["sortDir"] = "-", - ["isolate"] = 1, - ["size"] = 32, - }, + ["showBy"] = "LEFT_DOWN", + ["wrapAfter"] = 12, + ["maxWraps"] = 3, + ["wrapXOffset"] = 6, + ["wrapYOffset"] = 16, + ["sortMethod"] = "TIME", + ["sortDir"] = "-", + ["isolate"] = 1, + ["size"] = 32, + }, ["debuffs"] = { - ["showBy"] = "LEFT_DOWN", - ["wrapAfter"] = 12, - ["maxWraps"] = 1, - ["wrapXOffset"] = 6, - ["wrapYOffset"] = 16, - ["sortMethod"] = "TIME", - ["sortDir"] = "-", - ["isolate"] = 1, - ["size"] = 32, + ["showBy"] = "LEFT_DOWN", + ["wrapAfter"] = 12, + ["maxWraps"] = 1, + ["wrapXOffset"] = 6, + ["wrapYOffset"] = 16, + ["sortMethod"] = "TIME", + ["sortDir"] = "-", + ["isolate"] = 1, + ["size"] = 32, }, }; local auraOptionsTemplate = { scaleGroup = { - order = 1, - guiInline = true, - type = "group", - name = L["Scale Options"], + order = 1, + guiInline = true, + type = "group", + name = L["Scale Options"], args = { size = { - type = "range", - name = L["Size"], - desc = L["Set the size of the individual auras."], - min = 16, - max = 60, - step = 2, + type = "range", + name = L["Size"], + desc = L["Set the size of the individual auras."], + min = 16, + max = 60, + step = 2, order = 1 }, wrapXOffset = { - order = 2, - type = "range", - name = L["Horizontal Spacing"], - min = 0, - max = 50, + order = 2, + type = "range", + name = L["Horizontal Spacing"], + min = 0, + max = 50, step = 1 }, wrapYOffset = { - order = 3, - type = "range", - name = L["Vertical Spacing"], - min = 0, - max = 50, + order = 3, + type = "range", + name = L["Vertical Spacing"], + min = 0, + max = 50, step = 1 }, } }, layoutGroup = { - order = 2, - guiInline = true, - type = "group", - name = L["Directional Options"], + order = 2, + guiInline = true, + type = "group", + name = L["Directional Options"], args = { showBy = { - type = "select", - order = 1, - name = L["Growth Direction"], - desc = L["The direction the auras will grow and then the direction they will grow after they reach the wrap after limit."], + type = "select", + order = 1, + name = L["Growth Direction"], + desc = L["The direction the auras will grow and then the direction they will grow after they reach the wrap after limit."], values = { - DOWN_RIGHT = format(L["%s and then %s"], L["Down"], L["Right"]), - DOWN_LEFT = format(L["%s and then %s"], L["Down"], L["Left"]), - UP_RIGHT = format(L["%s and then %s"], L["Up"], L["Right"]), - UP_LEFT = format(L["%s and then %s"], L["Up"], L["Left"]), - RIGHT_DOWN = format(L["%s and then %s"], L["Right"], L["Down"]), - RIGHT_UP = format(L["%s and then %s"], L["Right"], L["Up"]), - LEFT_DOWN = format(L["%s and then %s"], L["Left"], L["Down"]), + DOWN_RIGHT = format(L["%s and then %s"], L["Down"], L["Right"]), + DOWN_LEFT = format(L["%s and then %s"], L["Down"], L["Left"]), + UP_RIGHT = format(L["%s and then %s"], L["Up"], L["Right"]), + UP_LEFT = format(L["%s and then %s"], L["Up"], L["Left"]), + RIGHT_DOWN = format(L["%s and then %s"], L["Right"], L["Down"]), + RIGHT_UP = format(L["%s and then %s"], L["Right"], L["Up"]), + LEFT_DOWN = format(L["%s and then %s"], L["Left"], L["Down"]), LEFT_UP = format(L["%s and then %s"], L["Left"], L["Up"]) } }, wrapAfter = { - type = "range", - order = 2, - name = L["Wrap After"], - desc = L["Begin a new row or column after this many auras."], - min = 1, - max = 32, + type = "range", + order = 2, + name = L["Wrap After"], + desc = L["Begin a new row or column after this many auras."], + min = 1, + max = 32, step = 1 }, maxWraps = { - name = L["Max Wraps"], - order = 3, - desc = L["Limit the number of rows or columns."], - type = "range", - min = 1, - max = 32, + name = L["Max Wraps"], + order = 3, + desc = L["Limit the number of rows or columns."], + type = "range", + min = 1, + max = 32, step = 1 }, } }, sortGroup = { - order = 1, - guiInline = true, - type = "group", - name = L["Sorting Options"], + order = 1, + guiInline = true, + type = "group", + name = L["Sorting Options"], args = { sortMethod = { - order = 1, - name = L["Sort Method"], - desc = L["Defines how the group is sorted."], - type = "select", + order = 1, + name = L["Sort Method"], + desc = L["Defines how the group is sorted."], + type = "select", values = { - ["INDEX"] = L["Index"], - ["TIME"] = L["Time"], + ["INDEX"] = L["Index"], + ["TIME"] = L["Time"], ["NAME"] = L["Name"] } }, sortDir = { - order = 2, - name = L["Sort Direction"], - desc = L["Defines the sort order of the selected sort method."], - type = "select", + order = 2, + name = L["Sort Direction"], + desc = L["Defines the sort order of the selected sort method."], + type = "select", values = { - ["+"] = L["Ascending"], + ["+"] = L["Ascending"], ["-"] = L["Descending"] } }, isolate = { - order = 3, - name = L["Seperate"], - desc = L["Indicate whether buffs you cast yourself should be separated before or after."], - type = "select", + order = 3, + name = L["Seperate"], + desc = L["Indicate whether buffs you cast yourself should be separated before or after."], + type = "select", values = { - [-1] = L["Other's First"], - [0] = L["No Sorting"], + [-1] = L["Other's First"], + [0] = L["No Sorting"], [1] = L["Your Auras First"] } } @@ -188,11 +188,11 @@ local auraOptionsTemplate = { }, } -function MOD:LoadOptions() +function MOD:LoadOptions() SV.Options.args[Schema] = { - type = "group", - name = Schema, - childGroups = "tab", + type = "group", + name = Schema, + childGroups = "tab", get = function(a)return SV.db[Schema][a[#a]] end, set = function(a,b) MOD:ChangeDBVar(b,a[#a]); @@ -203,97 +203,97 @@ function MOD:LoadOptions() intro = { order = 1, width = 'full', - type = "description", + type = "description", name = L["AURAS_DESC"] }, aurasEnabled = { - order = 2, - type = "toggle", + order = 2, + type = "toggle", name = L["Auras Enabled"], get = function(a) return SV.db[Schema].aurasEnabled end, set = function(a,b)SV.db[Schema].aurasEnabled = b;SV:StaticPopup_Show("RL_CLIENT") end }, hyperBuffsEnabled = { - order = 3, - type = "toggle", + order = 3, + type = "toggle", name = L["Hyper Auras Enabled"], get = function(a)return SV.db[Schema].hyperBuffsEnabled end, set = function(a,b)SV.db[Schema].hyperBuffsEnabled = b;SV:StaticPopup_Show("RL_CLIENT")end }, hyperBuffsFiltered = { - order = 4, - type = "toggle", + order = 4, + type = "toggle", name = L["Hyper Auras Filtered"], get = function(a)return SV.db[Schema].hyperBuffsFiltered end, set = function(a,b)SV.db[Schema].hyperBuffsFiltered = b;SV:StaticPopup_Show("RL_CLIENT")end }, auraGroups = { - order = 5, - type = "group", - name = L["Options"], + order = 5, + type = "group", + name = L["Options"], childGroups = "tree", disabled = function() return not SV.db[Schema].aurasEnabled end, args = { common = { - order = 10, - type = "group", - name = L["General"], + order = 10, + type = "group", + name = L["General"], args = { fadeBy = { - type = "range", - name = L["Fade Threshold"], - desc = L["Threshold before text changes red, goes into decimal form, and the icon will fade. Set to -1 to disable."], - min = -1, - max = 30, - step = 1, + type = "range", + name = L["Fade Threshold"], + desc = L["Threshold before text changes red, goes into decimal form, and the icon will fade. Set to -1 to disable."], + min = -1, + max = 30, + step = 1, order = 1 }, timeOffsetH = { - order = 2, - name = L["Time xOffset"], - type = "range", - min = -60, - max = 60, + order = 2, + name = L["Time xOffset"], + type = "range", + min = -60, + max = 60, step = 1 }, timeOffsetV = { - order = 3, - name = L["Time yOffset"], - type = "range", - min = -60, - max = 60, + order = 3, + name = L["Time yOffset"], + type = "range", + min = -60, + max = 60, step = 1 }, countOffsetH = { - order = 4, - name = L["Count xOffset"], - type = "range", - min = -60, - max = 60, + order = 4, + name = L["Count xOffset"], + type = "range", + min = -60, + max = 60, step = 1 }, countOffsetV = { - order = 5, - name = L["Count yOffset"], - type = "range", - min = -60, - max = 60, + order = 5, + name = L["Count yOffset"], + type = "range", + min = -60, + max = 60, step = 1 } } }, buffs = { - order = 30, - type = "group", - name = L["Buffs"], + order = 30, + type = "group", + name = L["Buffs"], get = function(b)return SV.db[Schema].buffs[b[#b]]end, set = function(a,b)MOD:ChangeDBVar(b,a[#a],"buffs");MOD:UpdateAuraHeader(SVUI_PlayerBuffs, "buffs")end, args = auraOptionsTemplate }, debuffs = { - order = 40, - type = "group", - name = L["Debuffs"], + order = 40, + type = "group", + name = L["Debuffs"], get = function(b)return SV.db[Schema].debuffs[b[#b]]end, set = function(a,b)MOD:ChangeDBVar(b,a[#a],"debuffs");MOD:UpdateAuraHeader(SVUI_PlayerDebuffs, "debuffs")end, args = auraOptionsTemplate @@ -302,4 +302,4 @@ function MOD:LoadOptions() }, } } -end \ No newline at end of file +end diff --git a/SVUI_Auras/components/procs.lua b/SVUI_Auras/components/procs.lua index 43922fb..00756c3 100644 --- a/SVUI_Auras/components/procs.lua +++ b/SVUI_Auras/components/procs.lua @@ -1,7 +1,7 @@ --[[ ########################################################## S V U I By: Munglunch -########################################################## +########################################################## LOCALIZED LUA FUNCTIONS ########################################################## ]]-- @@ -52,8 +52,8 @@ local RegisterStateDriver = _G.RegisterStateDriver; local UnregisterStateDriver = _G.UnregisterStateDriver; local RegisterAttributeDriver = _G.RegisterAttributeDriver; local GetRaidBuffTrayAuraInfo = _G.GetRaidBuffTrayAuraInfo; ---[[ -########################################################## +--[[ +########################################################## GET ADDON DATA ########################################################## ]]-- @@ -61,33 +61,32 @@ local SV = _G['SVUI'] local L = SV.L local MOD = SV.Auras; if(not MOD) then return end; ---[[ -########################################################## +--[[ +########################################################## LOCAL VARS ########################################################## ]]-- local GUIDs = {}; -local RunningProcs = {}; local ProcWatch = CreateFrame('Frame', 'SVUI_ProcWatch', UIParent); local function CreateProcIcon() local proc = CreateFrame("Frame", nil, ProcWatch) proc:SetBackdrop({ - bgFile = [[Interface\BUTTONS\WHITE8X8]], - tile = false, - tileSize = 0, - edgeFile = [[Interface\BUTTONS\WHITE8X8]], - edgeSize = 2, + bgFile = [[Interface\BUTTONS\WHITE8X8]], + tile = false, + tileSize = 0, + edgeFile = [[Interface\BUTTONS\WHITE8X8]], + edgeSize = 2, insets = { - left = 0, - right = 0, - top = 0, + left = 0, + right = 0, + top = 0, bottom = 0 } }) proc:SetBackdropColor(0, 0, 0) proc:SetBackdropBorderColor(0, 0, 0) - + proc.icon = proc:CreateTexture(nil, "BORDER") proc.icon:InsetPoints(proc, 2, 2) proc.icon:SetTexCoord(unpack(_G.SVUI_ICON_COORDS)) @@ -100,14 +99,7 @@ local function CreateProcIcon() proc.time:SetPoint("TOP", proc, "BOTTOM", 1 + SV.db.Auras.timeOffsetH, 0 + SV.db.Auras.timeOffsetV) proc.time:SetFontObject(SVUI_Font_Aura) - proc.cd = CreateFrame("Cooldown", nil, proc) - proc.cd:SetAllPoints(proc) - proc.cd:SetFrameLevel(proc:GetFrameLevel() + 10) - proc.cd:SetReverse(true) - --proc.cd:SetDrawEdge(false) - --proc.cd:SetDrawBling(false) - proc.cd:SetSwipeColor(0, 0, 0, 1) - proc.cd:SetAlpha(1) + proc.cd = SV.API:CD(proc); proc.highlight = proc:CreateTexture(nil, "HIGHLIGHT") proc.highlight:SetTexture(SV.media.statusbar.default) @@ -118,13 +110,13 @@ local function CreateProcIcon() return proc; end ---[[ -########################################################## +--[[ +########################################################## CORE FUNCTIONS ########################################################## ]]-- local setupGUID -do +do local cache = setmetatable({}, {__type = "k"}) local frame = CreateFrame"Frame" @@ -139,127 +131,97 @@ do end) frame:RegisterEvent"PLAYER_REGEN_ENABLED" frame:RegisterEvent"PLAYER_ENTERING_WORLD" - - function setupGUID(guid) - local t = next(cache) - if t then - cache[t] = nil - else - t = {} + + function setupGUID(unit) + if(not unit) then return false end + local guid = UnitGUID(unit) + if(not guid) then return false end + if(not GUIDs[guid]) then + local t = next(cache) + if t then + cache[t] = nil + else + t = {} + end + GUIDs[guid] = t end - GUIDs[guid] = t + return GUIDs[guid] end end -local function SetProcTimer(icon, count, duration, remaining) - icon:Show() - if icon.cd then - if duration and duration > 0 then - icon.cd:SetCooldown(remaining - duration, duration) - end - end - if icon.count then - icon.count:SetText((count > 1 and count)) +local function SetProcTimer(aura, count, duration, remaining) + aura:Show() + if duration and duration > 0 then + aura.cd:SetCooldown(remaining - duration, duration) end + aura.count:SetText((count > 1 and count)) end local PROC_UNIT_AURA = function(self, event, unit) - if not unit then return end - local index, icons = 1, ProcWatch.watched - local _, name, texture, count, duration, remaining, caster, key, aura, spellID + local CACHED_AURA = setupGUID(unit); + if(not CACHED_AURA) then return end + + local index = 1 + local PROCS = self.cache + local _, name, texture, count, duration, remaining, caster, key, spellID local filter = "HELPFUL" - local guid = UnitGUID(unit) - if not guid then return end - if not GUIDs[guid] then setupGUID(guid) end - - for _, icon in pairs(icons) do + + for _, icon in pairs(PROCS) do icon:Hide() end local x = 1 while true do name, _, texture, count, _, duration, remaining, caster, _, _, spellID = UnitAura(unit, index, filter) - if not name then + if not name then if filter == "HELPFUL" then filter = "HARMFUL" index = 1 else break end - else - if icons[spellID] then - aura = icons[spellID] + else + local aura = PROCS[spellID] + if(aura) then aura.timeLeft = remaining; - aura.first = true; - GUIDs[guid][spellID] = true; - RunningProcs[spellID] = true; + CACHED_AURA[spellID] = true; aura:ClearAllPoints() - aura:SetPoint('RIGHT', ProcWatch, 'RIGHT', -((x - 1) * 43), 0) - SetProcTimer(aura, count, duration, remaining); + aura:SetPoint('RIGHT', self, 'RIGHT', -((x - 1) * 43), 0) + aura:Show() + + if(duration and (duration > 0)) then + aura.cd:SetCooldown(remaining - duration, duration) + end + + local textCount = ''; + if(count and (count > 1)) then + textCount = count + end + aura.count:SetText(textCount); + x = x + 1 end index = index + 1 end end - - for key in pairs(GUIDs[guid]) do - if icons[key] and not RunningProcs[key] then - icons[key]:Hide() - end - end end function MOD:UpdateProcWatch() if(not SV.db.Auras.procsEnabled) then return end; - local PROCS = ProcWatch.cache or {}; - ProcWatch.watched = {} - for _,aura in pairs(PROCS) do - - local name, _, image = GetSpellInfo(aura.spellID) - - if name then - ProcWatch.watched[aura.spellID] = aura - end - end -end; - -function MOD:InitializeProcWatch() - if(not SV.db.Auras.procsEnabled) then return end; - - if(not SV.db.Filters.Procs) then - SV.db.Filters.Procs = {} - end - - local ProcsAnchor = CreateFrame('Frame', 'SVUI_ProcWatchFrame', SV.Screen) - ProcsAnchor:SetSize(172,40) - ProcsAnchor:SetPoint("TOPRIGHT",SV.Screen,"CENTER",-50,-50) - - ProcWatch:SetParent(ProcsAnchor) - ProcWatch:SetWidth(720) - ProcWatch:SetHeight(40) - ProcWatch:SetPoint('RIGHT',ProcsAnchor,'RIGHT',0,0) - ProcWatch.cache = {}; - ProcWatch.watched = {}; - ProcWatch:RegisterUnitEvent('UNIT_AURA',"player") - ProcWatch:SetScript('OnEvent', PROC_UNIT_AURA) - - SV:NewAnchor(ProcsAnchor, L["Procs Frame"]) - local PROCS = ProcWatch.cache; local pwSize = SV.db.Auras.procSize or 40; - --local list = SV.db.Filters.Procs - local list = SV.db.Filters.BuffWatch + local CONFIG = SV.db.Filters.BuffWatch; + --local CONFIG = SV.db.Filters.Procs local i = 1; - for procID,procData in pairs(list) do + for procID,procData in pairs(CONFIG) do local spellID = tonumber(procID); local spellName,_,spellTexture = GetSpellInfo(spellID) if spellName then - local proc; - if not PROCS[procID] then + local proc = PROCS[procID]; + + if(not proc) then proc = CreateProcIcon() PROCS[procID] = proc - else - proc = PROCS[procID] end; proc.name = spellName; @@ -270,16 +232,34 @@ function MOD:InitializeProcWatch() proc:ClearAllPoints() proc:SetPoint('RIGHT', ProcWatch, 'RIGHT', -((i - 1) * 43), 0) proc.icon:SetTexture(spellTexture) - proc:Hide() + proc:Hide(); - ProcWatch.cache[procID] = proc; - - if ProcWatch.watched then - ProcWatch.watched[procID] = proc - end i = i + 1 end end; +end; + +function MOD:InitializeProcWatch() + if(not SV.db.Auras.procsEnabled) then return end; + + if(not SV.db.Filters.Procs) then + SV.db.Filters.Procs = {} + end + + ProcWatch.cache = {}; + + local ProcsAnchor = CreateFrame('Frame', 'SVUI_ProcWatchFrame', SV.Screen) + ProcsAnchor:SetSize(172,40) + ProcsAnchor:SetPoint("TOPRIGHT", SV.Screen, "CENTER", -50, -50) + + ProcWatch:SetParent(ProcsAnchor) + ProcWatch:SetWidth(720) + ProcWatch:SetHeight(40) + ProcWatch:SetPoint('RIGHT', ProcsAnchor, 'RIGHT', 0, 0) + ProcWatch:RegisterUnitEvent('UNIT_AURA', "player") + ProcWatch:SetScript('OnEvent', PROC_UNIT_AURA) + + SV:NewAnchor(ProcsAnchor, L["Procs Frame"]) self:UpdateProcWatch() -end; \ No newline at end of file +end; diff --git a/SVUI_UnitFrames/SVUI_UnitFrames.lua b/SVUI_UnitFrames/SVUI_UnitFrames.lua index 744ef2f..a434fa4 100644 --- a/SVUI_UnitFrames/SVUI_UnitFrames.lua +++ b/SVUI_UnitFrames/SVUI_UnitFrames.lua @@ -1,7 +1,7 @@ --[[ ########################################################## S V U I By: Munglunch -########################################################## +########################################################## LOCALIZED LUA FUNCTIONS ########################################################## ]]-- @@ -50,16 +50,16 @@ local CUSTOM_CLASS_COLORS = _G.CUSTOM_CLASS_COLORS; local RegisterStateDriver = _G.RegisterStateDriver; local UnregisterStateDriver = _G.UnregisterStateDriver; local RegisterAttributeDriver = _G.RegisterAttributeDriver; ---[[ -########################################################## +--[[ +########################################################## GET ADDON DATA AND TEST FOR oUF ########################################################## ]]-- local SV = _G['SVUI'] local L = SV.L; local LSM = _G.LibStub("LibSharedMedia-3.0"); ---[[ -########################################################## +--[[ +########################################################## MODULE AND INNER CLASSES ########################################################## ]]-- @@ -69,40 +69,40 @@ assert(oUF_SVUI, "SVUI UnitFrames: unable to locate oUF.") MOD.Units = {} MOD.Headers = {} MOD.Dispellable = {} ---[[ -########################################################## +--[[ +########################################################## LOCALS ########################################################## ]]-- local LoadedUnitFrames, LoadedGroupHeaders; local ReversedUnit = { - ["target"] = true, - ["targettarget"] = true, - ["pettarget"] = true, + ["target"] = true, + ["targettarget"] = true, + ["pettarget"] = true, ["focustarget"] = true, - ["boss"] = true, - ["arena"] = true, + ["boss"] = true, + ["arena"] = true, }; local function FindAnchorFrame(frame, anchor, badPoint) - if badPoint or anchor == 'FRAME' then - if(frame.Gladiator and frame.Gladiator:IsShown()) then + if badPoint or anchor == 'FRAME' then + if(frame.Gladiator and frame.Gladiator:IsShown()) then return frame.Gladiator else - return frame + return frame end - elseif(anchor == 'TRINKET' and frame.Gladiator and frame.Gladiator:IsShown()) then + elseif(anchor == 'TRINKET' and frame.Gladiator and frame.Gladiator:IsShown()) then return frame.Gladiator elseif(anchor == 'BUFFS' and frame.Buffs and frame.Buffs:IsShown()) then - return frame.Buffs + return frame.Buffs elseif(anchor == 'DEBUFFS' and frame.Debuffs and frame.Debuffs:IsShown()) then - return frame.Debuffs - else + return frame.Debuffs + else return frame - end -end ---[[ -########################################################## + end +end +--[[ +########################################################## CORE FUNCTIONS ########################################################## ]]-- @@ -113,15 +113,15 @@ do local function deactivate(unitName) local frame; if type(unitName) == "string" then frame = _G[unitName] else frame = unitName end - if frame then + if frame then frame:UnregisterAllEvents() frame:Hide() frame:SetParent(dummy) if frame.healthbar then frame.healthbar:UnregisterAllEvents() end if frame.manabar then frame.manabar:UnregisterAllEvents() end if frame.spellbar then frame.spellbar:UnregisterAllEvents() end - if frame.powerBarAlt then frame.powerBarAlt:UnregisterAllEvents() end - end + if frame.powerBarAlt then frame.powerBarAlt:UnregisterAllEvents() end + end end function oUF_SVUI:DisableBlizzard(unit) @@ -213,7 +213,7 @@ function MOD:RefreshUnitColors() oUF_SVUI.colors.class[eclass] = {color.r, color.g, color.b} end end - local db = SV.media.extended.unitframes + local db = SV.media.extended.unitframes for i, setting in pairs(db) do if setting and type(setting) == "table" then if(setting[1]) then @@ -240,10 +240,10 @@ function MOD:RefreshAllUnitMedia() if(not SV.db.UnitFrames) then return end self:RefreshUnitColors() for unit,frame in pairs(self.Units)do - if SV.db.UnitFrames[frame.___key].enable then + if SV.db.UnitFrames[frame.___key].enable then frame:MediaUpdate() frame:UpdateAllElements() - end + end end for _,group in pairs(self.Headers) do group:MediaUpdate() @@ -255,12 +255,12 @@ function MOD:RefreshUnitFrames() if(InCombatLockdown()) then self:RegisterEvent("PLAYER_REGEN_ENABLED"); return end self:RefreshUnitColors() for unit,frame in pairs(self.Units)do - if(SV.db.UnitFrames[frame.___key].enable) then + if(SV.db.UnitFrames[frame.___key].enable) then frame:Enable() frame:Update() - else + else frame:Disable() - end + end end local _,groupType = IsInInstance() local raidDebuffs = SV.oUF_RaidDebuffs or oUF_RaidDebuffs; @@ -270,16 +270,16 @@ function MOD:RefreshUnitFrames() raidDebuffs:RegisterDebuffs(SV.db.Filters["Raid"]) else raidDebuffs:RegisterDebuffs(SV.db.Filters["CC"]) - end + end end for _,group in pairs(self.Headers) do group:Update() - if(group.Configure) then + if(group.Configure) then group:Configure() - end + end end - if SV.db.UnitFrames.disableBlizzard then + if SV.db.UnitFrames.disableBlizzard then oUF_SVUI:DisableBlizzard('party') end collectgarbage("collect") @@ -308,7 +308,7 @@ function MOD:RefreshUnitMedia(unitName) if(unitDB.name.fontOutline == 'NONE') then panel.Name:SetShadowOffset(1, -1) panel.Name:SetShadowColor(0, 0, 0, 1) - else + else panel.Name:SetShadowOffset(2, -2) panel.Name:SetShadowColor(0, 0, 0, 0.75) end @@ -377,7 +377,7 @@ function MOD:RefreshUnitLayout(frame, template) if(PORTRAIT_ENABLED and (not PORTRAIT_OVERLAY)) then if(PORTRAIT_STYLE == '2D') then PORTRAIT_WIDTH = ((UNIT_HEIGHT * TOP_MODIFIER) + (1 * TOP_MODIFIER)); - else + else PORTRAIT_WIDTH = ((db.portrait.width * TOP_MODIFIER) + (1 * TOP_MODIFIER)); end end @@ -396,7 +396,7 @@ function MOD:RefreshUnitLayout(frame, template) PORTRAIT_GRIP = frame.PortraitModel; end else - PORTRAIT_GRIP = frame.Portrait; + PORTRAIT_GRIP = frame.Portrait; end end @@ -431,27 +431,27 @@ function MOD:RefreshUnitLayout(frame, template) --[[ THREAT LAYOUT ]]-- - if frame.Threat then + if frame.Threat then local threat = frame.Threat; - if db.threatEnabled then - if not frame:IsElementEnabled('Threat')then + if db.threatEnabled then + if not frame:IsElementEnabled('Threat')then frame:EnableElement('Threat') - end - elseif frame:IsElementEnabled('Threat')then + end + elseif frame:IsElementEnabled('Threat')then frame:DisableElement('Threat') - end - end + end + end --[[ TARGETGLOW LAYOUT ]]-- - if frame.TargetGlow then + if frame.TargetGlow then local glow = frame.TargetGlow; glow:ClearAllPoints() glow:ModPoint("TOPLEFT", -3, 3) glow:ModPoint("TOPRIGHT", 3, 3) glow:ModPoint("BOTTOMLEFT", -3, -3) glow:ModPoint("BOTTOMRIGHT", 3, -3) - end + end --[[ INFO TEXTS ]]-- local point,cX,cY; @@ -488,7 +488,7 @@ function MOD:RefreshUnitLayout(frame, template) else nametext:SetJustifyV("MIDDLE") end - + frame:Tag(nametext, db.name.tags) end end @@ -536,7 +536,7 @@ function MOD:RefreshUnitLayout(frame, template) --[[ HEALTH LAYOUT ]]-- - do + do local health = frame.Health; if(db.health and (db.health.reversed ~= nil)) then health.fillInverted = db.health.reversed; @@ -582,20 +582,20 @@ function MOD:RefreshUnitLayout(frame, template) if(frame.RefreshHealthBar) then frame:RefreshHealthBar(PORTRAIT_OVERLAY) end - end + end --[[ POWER LAYOUT ]]-- do if(POWER_GRIP) then - if(POWER_ENABLED) then - if(not frame:IsElementEnabled('Power')) then + if(POWER_ENABLED) then + if(not frame:IsElementEnabled('Power')) then frame:EnableElement('Power') POWER_GRIP:Show() end POWER_GRIP.Smooth = SV.db.UnitFrames.smoothbars; - + POWER_GRIP.colorClass = nil; POWER_GRIP.colorReaction = nil; POWER_GRIP.colorPower = nil; @@ -603,7 +603,7 @@ function MOD:RefreshUnitLayout(frame, template) local CLASSCOLOR = db.power.classColor or false; POWER_GRIP.colorClass = CLASSCOLOR; POWER_GRIP.colorReaction = CLASSCOLOR; - POWER_GRIP.colorPower = (not CLASSCOLOR); + POWER_GRIP.colorPower = (not CLASSCOLOR); POWER_GRIP.frequentUpdates = db.power.frequentUpdates; POWER_GRIP:ClearAllPoints() @@ -616,10 +616,10 @@ function MOD:RefreshUnitLayout(frame, template) POWER_GRIP:ModPoint(BOTTOM_ANCHOR1, frame, BOTTOM_ANCHOR1, (PORTRAIT_WIDTH - (1 * BOTTOM_MODIFIER)), 2) POWER_GRIP:ModPoint(BOTTOM_ANCHOR2, frame, BOTTOM_ANCHOR2, (2 * BOTTOM_MODIFIER), 2) end - elseif(frame:IsElementEnabled('Power')) then + elseif(frame:IsElementEnabled('Power')) then frame:DisableElement('Power') POWER_GRIP:Hide() - end + end end --[[ ALTPOWER LAYOUT ]]-- @@ -628,12 +628,12 @@ function MOD:RefreshUnitLayout(frame, template) local altPower = frame.AltPowerBar; local Alt_OnShow = function() MASTER_GRIP:ModPoint(TOP_ANCHOR2, PORTRAIT_WIDTH, -(POWER_HEIGHT + 1)) - end + end local Alt_OnHide = function() MASTER_GRIP:ModPoint(TOP_ANCHOR2, PORTRAIT_WIDTH, -1) altPower.text:SetText("") - end - if db.power.enable then + end + if db.power.enable then frame:EnableElement('AltPowerBar') if(TEXT_GRIP.Health) then altPower.text:SetFont(TEXT_GRIP.Health:GetFont()) @@ -645,11 +645,11 @@ function MOD:RefreshUnitLayout(frame, template) altPower.Smooth = SV.db.UnitFrames.smoothbars; altPower:HookScript("OnShow", Alt_OnShow) altPower:HookScript("OnHide", Alt_OnHide) - else + else frame:DisableElement('AltPowerBar') altPower.text:SetAlpha(0) altPower:Hide() - end + end end end @@ -659,30 +659,30 @@ function MOD:RefreshUnitLayout(frame, template) local PORTRAIT = frame.Portrait; if(PORTRAIT and PORTRAIT_ENABLED) then - if not frame:IsElementEnabled('Portrait')then + if not frame:IsElementEnabled('Portrait')then frame:EnableElement('Portrait') - end - + end + PORTRAIT_GRIP:SetAlpha(1) PORTRAIT_GRIP:ClearAllPoints() - if(PORTRAIT_OVERLAY) then + if(PORTRAIT_OVERLAY) then PORTRAIT_GRIP:SetAllPoints(MASTER_GRIP) else PORTRAIT_GRIP:ModPoint(TOP_ANCHOR2, frame, TOP_ANCHOR2, (1 * TOP_MODIFIER), -1) - PORTRAIT_GRIP:ModPoint(BOTTOM_ANCHOR2, MASTER_GRIP, BOTTOM_ANCHOR1, (1 * BOTTOM_MODIFIER), 1) + PORTRAIT_GRIP:ModPoint(BOTTOM_ANCHOR2, MASTER_GRIP, BOTTOM_ANCHOR1, (1 * BOTTOM_MODIFIER), 1) end if(PORTRAIT.ForceUpdate) then PORTRAIT:ForceUpdate() end PORTRAIT_GRIP:Show() - else + else PORTRAIT_GRIP:Hide() - if frame:IsElementEnabled('Portrait') then + if frame:IsElementEnabled('Portrait') then frame:DisableElement('Portrait') - end + end end - end + end --[[ CASTBAR LAYOUT ]]-- @@ -700,7 +700,7 @@ function MOD:RefreshUnitLayout(frame, template) local lazerScale = castHeight * 1.8; if(db.castbar.format) then castbar.TimeFormat = db.castbar.format end - + if(not castbar.pewpew) then castbar:SetSize(castWidth, castHeight) elseif(castbar:GetHeight() ~= lazerScale) then @@ -719,7 +719,7 @@ function MOD:RefreshUnitLayout(frame, template) else castbar.Spark:Hide() end - end + end castbar:SetFrameStrata("HIGH") if castbar.Holder then castbar.Holder:SetSize((castWidth + 2), (castHeight + 6)) @@ -729,10 +729,10 @@ function MOD:RefreshUnitLayout(frame, template) end end castbar:GetStatusBarTexture():SetHorizTile(false) - if db.castbar.latency then + if db.castbar.latency then castbar.SafeZone = castbar.LatencyTexture; castbar.LatencyTexture:Show() - else + else castbar.SafeZone = nil; castbar.LatencyTexture:Hide() end @@ -747,10 +747,10 @@ function MOD:RefreshUnitLayout(frame, template) castbar.Organizer.Icon:SetAllPoints(castbar.Organizer) castbar.Organizer.Icon:Show() else - castbar.Organizer.Icon:Hide() - end + castbar.Organizer.Icon:Hide() + end end - + local cr,cg,cb if(db.castbar.useCustomColor) then cr,cg,cb = db.castbar.castingColor[1], db.castbar.castingColor[2], db.castbar.castingColor[3]; @@ -762,24 +762,24 @@ function MOD:RefreshUnitLayout(frame, template) castbar.SparkColor = oUF_SVUI.colors.spark end - if db.castbar.enable and not frame:IsElementEnabled('Castbar')then + if db.castbar.enable and not frame:IsElementEnabled('Castbar')then frame:EnableElement('Castbar') elseif not db.castbar.enable and frame:IsElementEnabled('Castbar')then - frame:DisableElement('Castbar') + frame:DisableElement('Castbar') end - end + end --[[ AURA LAYOUT ]]-- if(BUFF_GRIP or DEBUFF_GRIP) then if((not BUFF_ENABLED) and (not DEBUFF_ENABLED)) then - if(frame:IsElementEnabled('Aura')) then + if(frame:IsElementEnabled('Aura')) then frame:DisableElement('Aura') end BUFF_GRIP:Hide() DEBUFF_GRIP:Hide() else - if(not frame:IsElementEnabled('Aura')) then + if(not frame:IsElementEnabled('Aura')) then frame:EnableElement('Aura') end if(BUFF_GRIP) then @@ -843,7 +843,7 @@ function MOD:RefreshUnitLayout(frame, template) BUFF_GRIP:ForceUpdate() else BUFF_GRIP:Hide() - end + end end if(DEBUFF_GRIP) then if(DEBUFF_ENABLED) then @@ -863,12 +863,10 @@ function MOD:RefreshUnitLayout(frame, template) else DEBUFF_GRIP.down = false end - --if(template == 'player') then print('WIPING DEBUFF ICONS') end for i = 1, #DEBUFF_GRIP.Icons do DEBUFF_GRIP.Icons[i]:Hide() end else - --if(template == 'player') then print('WIPING DEBUFF BARS') end for i = 1, #DEBUFF_GRIP.Bars do DEBUFF_GRIP.Bars[i]:Hide() end @@ -894,7 +892,7 @@ function MOD:RefreshUnitLayout(frame, template) if(attachTo == 'BUFFS' and (not BUFF_ENABLED)) then attachTo = 'FRAME' end - + local attachAnchor = FindAnchorFrame(frame, attachTo, attachTo == 'BUFFS' and db.buffs.attachTo == 'DEBUFFS') DEBUFF_GRIP:ClearAllPoints() SV:SetReversePoint(DEBUFF_GRIP, db.debuffs.anchorPoint, attachAnchor, db.debuffs.xOffset + BOTTOM_MODIFIER, db.debuffs.yOffset) @@ -904,10 +902,10 @@ function MOD:RefreshUnitLayout(frame, template) DEBUFF_GRIP:ForceUpdate() else DEBUFF_GRIP:Hide() - end + end end end - end + end --[[ ICON LAYOUTS ]]-- @@ -916,7 +914,7 @@ function MOD:RefreshUnitLayout(frame, template) local ico = db.icons; --[[ CLASS ICON ]]-- - + if(ico.classIcon and frame.ActionPanel.class) then local classIcon = frame.ActionPanel.class; if ico.classIcon.enable then @@ -927,7 +925,7 @@ function MOD:RefreshUnitLayout(frame, template) classIcon:SetAlpha(1) classIcon:ModSize(size) SV:SetReversePoint(classIcon, ico.classIcon.attachTo, MASTER_GRIP, ico.classIcon.xOffset, ico.classIcon.yOffset) - else + else classIcon:Hide() end end @@ -951,7 +949,7 @@ function MOD:RefreshUnitLayout(frame, template) raidIcon:ModSize(size) SV:SetReversePoint(raidIcon, ico.raidicon.attachTo, MASTER_GRIP, ico.raidicon.xOffset, ico.raidicon.yOffset) end - else + else frame:DisableElement('RaidIcon') raidIcon:Hide() end @@ -959,7 +957,7 @@ function MOD:RefreshUnitLayout(frame, template) --[[ ROLEICON ]]-- - if(ico.roleIcon and frame.LFDRole) then + if(ico.roleIcon and frame.LFDRole) then local lfd = frame.LFDRole; if(not MINI_GRID and ico.roleIcon.enable) then lfd:Show() @@ -976,15 +974,15 @@ function MOD:RefreshUnitLayout(frame, template) lfd:ModSize(size) SV:SetReversePoint(lfd, ico.roleIcon.attachTo, MASTER_GRIP, ico.roleIcon.xOffset, ico.roleIcon.yOffset) end - else + else frame:DisableElement('LFDRole') lfd:Hide() - end - end + end + end --[[ RAIDROLEICON ]]-- - if(ico.raidRoleIcons and frame.RaidRoleFramesAnchor) then + if(ico.raidRoleIcons and frame.RaidRoleFramesAnchor) then local roles = frame.RaidRoleFramesAnchor; if(not MINI_GRID and ico.raidRoleIcons.enable) then roles:Show() @@ -1002,29 +1000,29 @@ function MOD:RefreshUnitLayout(frame, template) roles:ModSize(size) SV:SetReversePoint(roles, ico.raidRoleIcons.attachTo, MASTER_GRIP, ico.raidRoleIcons.xOffset, ico.raidRoleIcons.yOffset) end - else + else roles:Hide() frame:DisableElement('Leader') frame:DisableElement('MasterLooter') - end - end + end + end - end + end end --[[ HEAL PREDICTION LAYOUT ]]-- if frame.HealPrediction then - if db.predict then - if not frame:IsElementEnabled('HealPrediction')then + if db.predict then + if not frame:IsElementEnabled('HealPrediction')then frame:EnableElement('HealPrediction') - end - else - if frame:IsElementEnabled('HealPrediction')then + end + else + if frame:IsElementEnabled('HealPrediction')then frame:DisableElement('HealPrediction') - end + end end - end + end --[[ DEBUFF HIGHLIGHT LAYOUT ]]-- @@ -1034,10 +1032,10 @@ function MOD:RefreshUnitLayout(frame, template) frame.Afflicted:SetTexture(SV.BaseTexture) end frame:EnableElement('Afflicted') - else + else frame:DisableElement('Afflicted') end - end + end --[[ RANGE CHECK LAYOUT ]]-- @@ -1048,30 +1046,30 @@ function MOD:RefreshUnitLayout(frame, template) frame.Range.outsideAlpha = SV.db.UnitFrames.OORAlpha or 1 end - if db.rangeCheck then - if not frame:IsElementEnabled('Range')then + if db.rangeCheck then + if not frame:IsElementEnabled('Range')then frame:EnableElement('Range') - end - else - if frame:IsElementEnabled('Range')then + end + else + if frame:IsElementEnabled('Range')then frame:DisableElement('Range') - end - end + end + end end --[[ AURA WATCH LAYOUT ]]-- if(frame.AuraWatch) then if(db.auraWatch) then - if db.auraWatch.enable then - if not frame:IsElementEnabled('AuraWatch')then + if db.auraWatch.enable then + if not frame:IsElementEnabled('AuraWatch')then frame:EnableElement('AuraWatch') end frame.AuraWatch:ForceUpdate() - else - if frame:IsElementEnabled('AuraWatch')then + else + if frame:IsElementEnabled('AuraWatch')then frame:DisableElement('AuraWatch') - end + end end end end @@ -1088,8 +1086,8 @@ function MOD:RefreshUnitLayout(frame, template) self:PostRefreshUpdate(frame, template) end end ---[[ -########################################################## +--[[ +########################################################## EVENTS AND INITIALIZE ########################################################## ]]-- @@ -1126,22 +1124,22 @@ function MOD:KillBlizzardRaidFrames() _G.CompactRaidFrameContainer:Die() _G.CompactUnitFrameProfiles:Die() local crfmTest = CompactRaidFrameManager_GetSetting("IsShown") - if crfmTest and crfmTest ~= "0" then + if crfmTest and crfmTest ~= "0" then CompactRaidFrameManager_SetSetting("IsShown", "0") end end function MOD:PLAYER_REGEN_DISABLED() - for _,frame in pairs(self.Headers) do - if frame and frame.forceShow then + for _,frame in pairs(self.Headers) do + if frame and frame.forceShow then self:ViewGroupFrames(frame) - end + end end for _,frame in pairs(self.Units) do - if(frame and frame.forceShow and frame.Restrict) then + if(frame and frame.forceShow and frame.Restrict) then frame:Restrict() - end + end end end @@ -1167,8 +1165,8 @@ end local UnitFrameThreatIndicator_Hook = function(unit, unitFrame) unitFrame:UnregisterAllEvents() end ---[[ -########################################################## +--[[ +########################################################## CLASS SPECIFIC INFO ########################################################## ]]-- @@ -1195,36 +1193,36 @@ elseif(PlayerClass == "PALADIN") then end local function GetTalentInfo(arg) - if type(arg) == "number" then + if type(arg) == "number" then return arg == GetActiveSpecGroup(); else return false; - end + end end function MOD:CanClassDispel() - if RefMagicSpec then - if(GetTalentInfo(RefMagicSpec)) then - self.Dispellable["Magic"] = true + if RefMagicSpec then + if(GetTalentInfo(RefMagicSpec)) then + self.Dispellable["Magic"] = true elseif(self.Dispellable["Magic"]) then - self.Dispellable["Magic"] = nil + self.Dispellable["Magic"] = nil end end -end +end function MOD:SPELLS_CHANGED() if (PlayerClass ~= "DRUID") then self:UnregisterEvent("SPELLS_CHANGED") - return - end - if GetSpellInfo(droodSpell1) == droodSpell2 then - self.Dispellable["Disease"] = true + return + end + if GetSpellInfo(droodSpell1) == droodSpell2 then + self.Dispellable["Disease"] = true elseif(self.Dispellable["Disease"]) then - self.Dispellable["Disease"] = nil + self.Dispellable["Disease"] = nil end end ---[[ -########################################################## +--[[ +########################################################## BUILD FUNCTION / UPDATE ########################################################## ]]-- @@ -1251,7 +1249,7 @@ function MOD:Load() self:RegisterEvent("UNIT_INVENTORY_CHANGED", "CanClassDispel") self:RegisterEvent("UPDATE_BONUS_ACTIONBAR", "CanClassDispel") - if(SV.db.UnitFrames.disableBlizzard) then + if(SV.db.UnitFrames.disableBlizzard) then self:KillBlizzardRaidFrames() hooksecurefunc("CompactUnitFrame_RegisterEvents", CompactUnitFrame_UnregisterEvents) hooksecurefunc("UnitFrameThreatIndicator_Initialize", UnitFrameThreatIndicator_Hook) @@ -1275,23 +1273,23 @@ function MOD:Load() InterfaceOptionsDisplayPanelShowAggroPercentage:SetScale(0.0001) InterfaceOptionsDisplayPanelShowAggroPercentage:SetAlpha(0) - if not IsAddOnLoaded("Blizzard_ArenaUI") then + if not IsAddOnLoaded("Blizzard_ArenaUI") then self:RegisterEvent("ADDON_LOADED") - else + else oUF_SVUI:DisableBlizzard("arena") end self:RegisterEvent("GROUP_ROSTER_UPDATE", "KillBlizzardRaidFrames") UIParent:UnregisterEvent("GROUP_ROSTER_UPDATE") - else + else CompactUnitFrameProfiles:RegisterEvent("VARIABLES_LOADED") end SV.Events:On("AURA_FILTER_OPTIONS_CHANGED", UpdateUnitFrames, true); - + local rDebuffs = SV.oUF_RaidDebuffs or oUF_RaidDebuffs; if not rDebuffs then return end rDebuffs.ShowDispelableDebuff = true; rDebuffs.FilterDispellableDebuff = true; rDebuffs.MatchBySpellName = true; -end \ No newline at end of file +end diff --git a/SVUI_UnitFrames/elements/auras.lua b/SVUI_UnitFrames/elements/auras.lua index 9bf68ff..fa49dbc 100644 --- a/SVUI_UnitFrames/elements/auras.lua +++ b/SVUI_UnitFrames/elements/auras.lua @@ -1,7 +1,7 @@ --[[ ########################################################## S V U I By: Munglunch -########################################################## +########################################################## LOCALIZED LUA FUNCTIONS ########################################################## ]]-- @@ -43,8 +43,8 @@ local tremove = table.remove; local CreateFrame = _G.CreateFrame; local InCombatLockdown = _G.InCombatLockdown; local GameTooltip = _G.GameTooltip; ---[[ -########################################################## +--[[ +########################################################## GET ADDON DATA ########################################################## ]]-- @@ -53,7 +53,7 @@ local L = SV.L; local LSM = _G.LibStub("LibSharedMedia-3.0") local MOD = SV.UnitFrames -if(not MOD) then return end +if(not MOD) then return end local oUF_SVUI = MOD.oUF assert(oUF_SVUI, "SVUI UnitFrames: unable to locate oUF.") @@ -73,17 +73,17 @@ local DebuffTypeColor = _G.DebuffTypeColor; local SVUI_Font_UnitAura = _G.SVUI_Font_UnitAura; local SVUI_Font_UnitAura_Bar = _G.SVUI_Font_UnitAura_Bar; ---[[ -########################################################## +--[[ +########################################################## LOCAL FUNCTIONS ########################################################## ]]-- local FilterAura_OnClick = function(self) - if not IsShiftKeyDown() then return end + if not IsShiftKeyDown() then return end local name = self.name; local filterKey = tostring(self.spellID) - if name and filterKey then + if name and filterKey then SV:AddonMessage((L["The spell '%s' has been added to the BlackList unitframe aura filter."]):format(name)) SV.db.Filters["BlackList"][filterKey] = {["enable"] = true} MOD:RefreshUnitFrames() @@ -113,15 +113,15 @@ local CreateAuraIcon = function(icons, index) aura:SetHeight(baseSize) aura:SetBackdrop({ - bgFile = [[Interface\BUTTONS\WHITE8X8]], - tile = false, - tileSize = 0, - edgeFile = [[Interface\BUTTONS\WHITE8X8]], - edgeSize = 1, + bgFile = [[Interface\BUTTONS\WHITE8X8]], + tile = false, + tileSize = 0, + edgeFile = [[Interface\BUTTONS\WHITE8X8]], + edgeSize = 1, insets = { - left = 0, - right = 0, - top = 0, + left = 0, + right = 0, + top = 0, bottom = 0 } }) @@ -216,10 +216,10 @@ local PostCreateAuraBars = function(self) bar.spellname:SetJustifyV'CENTER' bar.spellname:SetPoint'LEFT' bar.spellname:SetPoint('RIGHT', bar.spelltime, 'LEFT') - + self:RegisterForClicks("RightButtonUp") self:SetScript("OnClick", FilterAura_OnClick) -end +end local PostBarUpdate = function(self, bar, spellID, isDebuff, debuffType) if((not bar) or (not bar:IsVisible())) then return end @@ -234,7 +234,7 @@ local PostBarUpdate = function(self, bar, spellID, isDebuff, debuffType) color = {DebuffTypeColor[debuffType].r, DebuffTypeColor[debuffType].g, DebuffTypeColor[debuffType].b} else color = DEBUFFS_COLOR; - end + end else color = BUFFS_COLOR; end @@ -248,20 +248,14 @@ local PostBarUpdate = function(self, bar, spellID, isDebuff, debuffType) end --[[ AURA FILTERING ]]-- ---self, this, unit, name, rank, texture, count, dtype, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff -local CommonAuraFilter = function(self, aura, unit, auraName, _, _, _, debuffType, duration, _, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossAura) + +local CommonAuraFilter = function(self, isEnemy, isPlayer, auraName, spellID, debuffType, duration, shouldConsolidate) local db = SV.db.UnitFrames[self.___unitkey] - if((not db) or (db and not db[self.___aurakey])) then + if((not db) or (db and not db[self.___aurakey])) then return false; end - local auraDB = db[self.___aurakey]; - local isPlayer = caster == "player" or caster == "vehicle"; - local isEnemy = UnitIsEnemy("player", unit); - if(aura) then - aura.isPlayer = isPlayer; - aura.priority = 0; - end + local auraDB = db[self.___aurakey]; local filterKey = tostring(spellID) if(auraDB.filterWhiteList and (not SV.db.Filters.WhiteList[filterKey])) then @@ -273,16 +267,16 @@ local CommonAuraFilter = function(self, aura, unit, auraName, _, _, _, debuffTyp return false end - if(auraDB.filterDispellable and (debuffType and not MOD.Dispellable[debuffType])) then + if(auraDB.filterDispellable and (debuffType and not MOD.Dispellable[debuffType])) then return false end - if(auraDB.filterRaid and shouldConsolidate) then - return false + if(auraDB.filterRaid and shouldConsolidate) then + return false end - if(auraDB.filterInfinite and ((not duration) or (duration and duration == 0))) then - return false + if(auraDB.filterInfinite and ((not duration) or (duration and duration == 0))) then + return false end local active = auraDB.useFilter @@ -290,7 +284,7 @@ local CommonAuraFilter = function(self, aura, unit, auraName, _, _, _, debuffTyp local spellDB = SV.db.Filters[active]; if(spellDB[filterKey] and spellDB[filterKey].enable) then return false - end + end end end return true @@ -299,30 +293,23 @@ end --[[ DETAILED AURA FILTERING ]]-- local function filter_test(setting, isEnemy) - if((not setting) or (setting and type(setting) ~= "table")) then + if((not setting) or (setting and type(setting) ~= "table")) then return false; end - if((setting.enemy and isEnemy) or (setting.friendly and (not isEnemy))) then + if((setting.enemy and isEnemy) or (setting.friendly and (not isEnemy))) then return true; end - return false + return false end -local DetailedAuraFilter = function(self, aura, unit, auraName, _, _, _, debuffType, duration, _, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossAura) +local DetailedAuraFilter = function(self, isEnemy, isPlayer, auraName, spellID, debuffType, duration, shouldConsolidate) local db = SV.db.UnitFrames[self.___unitkey] local auraType = self.___aurakey - if((not db) or (not auraType) or (db and (not db[auraType]))) then + if((not db) or (not auraType) or (db and (not db[auraType]))) then return false; end - local auraDB = db[self.___aurakey]; - local isPlayer = caster == "player" or caster == "vehicle" - local isEnemy = UnitIsEnemy("player", unit); - - if(aura) then - aura.isPlayer = isPlayer; - aura.priority = 0; - end + local auraDB = db[self.___aurakey]; local filterKey = tostring(spellID) if(filter_test(auraDB.filterAll, isEnemy)) then @@ -340,24 +327,24 @@ local DetailedAuraFilter = function(self, aura, unit, auraName, _, _, _, debuffT return false end end - if(filter_test(auraDB.filterRaid, isEnemy) and shouldConsolidate) then - return false + if(filter_test(auraDB.filterRaid, isEnemy) and shouldConsolidate) then + return false end - if(filter_test(auraDB.filterInfinite, isEnemy) and ((not duration) or (duration and duration == 0))) then - return false + if(filter_test(auraDB.filterInfinite, isEnemy) and ((not duration) or (duration and duration == 0))) then + return false end local active = auraDB.useFilter if(active and SV.db.Filters[active]) then local spellDB = SV.db.Filters[active]; if(spellDB[filterKey] and spellDB[filterKey].enable) then return false - end + end end end - return true + return true end ---[[ -########################################################## +--[[ +########################################################## BUILD FUNCTION ########################################################## ]]-- @@ -368,7 +355,7 @@ local BoolFilters = { ['arena'] = true, ['party'] = true, ['raid'] = true, - ['raidpet'] = true, + ['raidpet'] = true, }; function MOD:CreateAuraFrames(frame, unit, barsAvailable) @@ -404,14 +391,14 @@ function MOD:CreateAuraFrames(frame, unit, barsAvailable) debuffs.PostBarUpdate = PostBarUpdate; end end ---[[ -########################################################## +--[[ +########################################################## AURA WATCH ########################################################## ]]-- local PreForcedUpdate = function(self) local unit = self.___key; - if not SV.db.UnitFrames[unit] then return end + if not SV.db.UnitFrames[unit] then return end local db = SV.db.UnitFrames[unit].auraWatch; if not db then return end; if(unit == "pet" or unit == "raidpet") then @@ -440,8 +427,8 @@ function MOD:CreateAuraWatch(frame, unit) watch.PreForcedUpdate = PreForcedUpdate return watch end ---[[ -########################################################## +--[[ +########################################################## CUSTOM EVENT UPDATES ########################################################## ]]-- @@ -450,4 +437,4 @@ local function UpdateAuraMediaLocals() DEBUFFS_COLOR = oUF_SVUI.colors.debuff_bars or DEFAULT_DEBUFFS_COLOR; AURA_STATUSBAR = LSM:Fetch("statusbar", SV.db.UnitFrames.auraBarStatusbar); end -SV.Events:On("UNITFRAME_COLORS_UPDATED", UpdateAuraMediaLocals, true); \ No newline at end of file +SV.Events:On("UNITFRAME_COLORS_UPDATED", UpdateAuraMediaLocals, true); diff --git a/SVUI_UnitFrames/libs/oUF/elements/aura.lua b/SVUI_UnitFrames/libs/oUF/elements/aura.lua index fc5353e..49966b9 100644 --- a/SVUI_UnitFrames/libs/oUF/elements/aura.lua +++ b/SVUI_UnitFrames/libs/oUF/elements/aura.lua @@ -14,12 +14,13 @@ local format = string.format; local math = math; local floor = math.floor local ceil = math.ceil -local hugeMath = math.huge; -local min = math.min; +local hugeMath = math.huge; +local min = math.min; +local random = math.random; --TABLE -local table = _G.table; -local tsort = table.sort; -local tinsert = _G.tinsert; +local table = _G.table; +local tsort = table.sort; +local tinsert = _G.tinsert; --BLIZZARD API local GetTime = _G.GetTime; local CreateFrame = _G.CreateFrame; @@ -40,6 +41,8 @@ local DEBUFF_FILTER = 'HARMFUL'; local VISIBLE = 1; local HIDDEN = 0; +local DEMO_SPELLS = {47540, 47540, 47540, 47540, 47540} + local function FormatTime(seconds) if seconds < MINUTE then return ("%.1fs"):format(seconds) @@ -55,23 +58,23 @@ end local SORTING_METHODS = { ["TIME_REMAINING"] = function(a, b) local compA = a.noTime and hugeMath or a.expirationTime - local compB = b.noTime and hugeMath or b.expirationTime - return compA > compB + local compB = b.noTime and hugeMath or b.expirationTime + return compA > compB end, ["TIME_REMAINING_REVERSE"] = function(a, b) local compA = a.noTime and hugeMath or a.expirationTime - local compB = b.noTime and hugeMath or b.expirationTime - return compA < compB + local compB = b.noTime and hugeMath or b.expirationTime + return compA < compB end, ["TIME_DURATION"] = function(a, b) local compA = a.noTime and hugeMath or a.duration - local compB = b.noTime and hugeMath or b.duration - return compA > compB + local compB = b.noTime and hugeMath or b.duration + return compA > compB end, ["TIME_DURATION_REVERSE"] = function(a, b) local compA = a.noTime and hugeMath or a.duration - local compB = b.noTime and hugeMath or b.duration - return compA < compB + local compB = b.noTime and hugeMath or b.duration + return compA < compB end, ["NAME"] = function(a, b) return a.name > b.name @@ -80,31 +83,13 @@ local SORTING_METHODS = { local SetSorting = function(self, sorting) if(sorting) then - if((type(sorting) == "string") and SORTING_METHODS[sorting]) then + if((type(sorting) == "string") and SORTING_METHODS[sorting]) then self.sort = SORTING_METHODS[sorting]; else self.sort = SORTING_METHODS["TIME_REMAINING"]; end - else + else self.sort = nil; - end -end - -local genericFilter = function(self, frame, _, name, _, _, _, _, _, _, caster, _, shouldConsolidate) - local isPlayer - - if(caster == 'player' or caster == 'vehicle') then - isPlayer = true - end - - if((self.onlyShowPlayer and isPlayer) or (not self.onlyShowPlayer and name)) then - if(frame) then - frame.isPlayer = isPlayer - frame.owner = caster - end - if(not shouldConsolidate) then - return true - end end end @@ -142,13 +127,13 @@ end local AuraIcon_OnUpdate = function(self, elapsed) self.expiration = self.expiration - elapsed; - - if(self.nextUpdate > 0) then + + if(self.nextUpdate > 0) then self.nextUpdate = self.nextUpdate - elapsed; return; end - if(self.expiration <= 0) then + if(self.expiration <= 0) then self:SetScript("OnUpdate", nil) self.text:SetText('') return; @@ -159,9 +144,9 @@ local AuraIcon_OnUpdate = function(self, elapsed) if expires < 4 then self.nextUpdate = 0.051 self.text:SetFormattedText("|cffff0000%.1f|r", expires) - elseif expires < 60 then + elseif expires < 60 then self.nextUpdate = 0.51 - self.text:SetFormattedText("|cffffff00%d|r", floor(expires)) + self.text:SetFormattedText("|cffffff00%d|r", floor(expires)) elseif expires < 3600 then timeLeft = ceil(expires / 60); calc = floor((expires / 60) + .5); @@ -400,18 +385,18 @@ local CreateAuraBar = function(self, index) iconHolder:SetPoint('BOTTOMLEFT', frame, 'BOTTOMLEFT', 0, 0) iconHolder:SetWidth(frame:GetHeight()) iconHolder:SetBackdrop({ - bgFile = [[Interface\BUTTONS\WHITE8X8]], - edgeFile = [[Interface\BUTTONS\WHITE8X8]], - tile = false, - tileSize = 0, - edgeSize = 1, - insets = + bgFile = [[Interface\BUTTONS\WHITE8X8]], + edgeFile = [[Interface\BUTTONS\WHITE8X8]], + tile = false, + tileSize = 0, + edgeSize = 1, + insets = { - left = 0, - right = 0, - top = 0, - bottom = 0, - }, + left = 0, + right = 0, + top = 0, + bottom = 0, + }, }) iconHolder:SetBackdropColor(0,0,0,0.5) iconHolder:SetBackdropBorderColor(0,0,0) @@ -430,23 +415,23 @@ local CreateAuraBar = function(self, index) barHolder:SetPoint('BOTTOMLEFT', frame.iconHolder, 'BOTTOMRIGHT', self.gap, 0) barHolder:SetPoint('TOPRIGHT', frame, 'TOPRIGHT', 0, 0) barHolder:SetBackdrop({ - bgFile = [[Interface\BUTTONS\WHITE8X8]], - edgeFile = [[Interface\BUTTONS\WHITE8X8]], - tile = false, - tileSize = 0, - edgeSize = 1, - insets = + bgFile = [[Interface\BUTTONS\WHITE8X8]], + edgeFile = [[Interface\BUTTONS\WHITE8X8]], + tile = false, + tileSize = 0, + edgeSize = 1, + insets = { - left = 0, - right = 0, - top = 0, - bottom = 0, - }, + left = 0, + right = 0, + top = 0, + bottom = 0, + }, }) barHolder:SetBackdropColor(0,0,0,0.5) barHolder:SetBackdropBorderColor(0,0,0) frame.barHolder = barHolder - + -- the main bar frame.statusBar = CreateFrame("StatusBar", nil, frame.barHolder) frame.statusBar:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]]) @@ -458,7 +443,7 @@ local CreateAuraBar = function(self, index) spark:SetTexture([[Interface\CastingBar\UI-CastingBar-Spark]]); spark:SetWidth(12); spark:SetBlendMode("ADD"); - spark:SetPoint('CENTER', frame.statusBar:GetStatusBarTexture(), 'RIGHT') + spark:SetPoint('CENTER', frame.statusBar:GetStatusBarTexture(), 'RIGHT') frame.statusBar.spark = spark frame.statusBar.spelltime = frame.statusBar:CreateFontString(nil, 'ARTWORK') @@ -466,20 +451,20 @@ local CreateAuraBar = function(self, index) --print("New Bar #" .. index) - if self.PostCreateBar then + if self.PostCreateBar then self.PostCreateBar(frame) else frame.statusBar.spelltime:SetFont([[Fonts\FRIZQT__.TTF]], 10, "NONE") frame.statusBar.spelltime:SetTextColor(1 ,1, 1) frame.statusBar.spelltime:SetShadowOffset(1, -1) - frame.statusBar.spelltime:SetShadowColor(0, 0, 0) + frame.statusBar.spelltime:SetShadowColor(0, 0, 0) frame.statusBar.spelltime:SetJustifyH'RIGHT' frame.statusBar.spelltime:SetJustifyV'CENTER' frame.statusBar.spelltime:SetPoint'RIGHT' frame.statusBar.spellname:SetFont([[Fonts\FRIZQT__.TTF]], 10, "NONE") frame.statusBar.spellname:SetTextColor(1, 1, 1) frame.statusBar.spellname:SetShadowOffset(1, -1) - frame.statusBar.spellname:SetShadowColor(0, 0, 0) + frame.statusBar.spellname:SetShadowColor(0, 0, 0) frame.statusBar.spellname:SetJustifyH'LEFT' frame.statusBar.spellname:SetJustifyV'CENTER' frame.statusBar.spellname:SetPoint'LEFT' @@ -488,7 +473,7 @@ local CreateAuraBar = function(self, index) return frame end -local UpdateIconAuras = function(self, cache, unit, index, filter, visible, isFriend) +local UpdateIconAuras = function(self, cache, unit, index, filter, visible, isEnemy) if not unit then return; end local isDebuff = filter == DEBUFF_FILTER @@ -498,7 +483,7 @@ local UpdateIconAuras = function(self, cache, unit, index, filter, visible, isFr local name, rank, texture, count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff; if(self.forceShow) then - spellID = 47540 + spellID = DEMO_SPELLS[random(1, #DEMO_SPELLS)]; name, rank, texture = GetSpellInfo(spellID) count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, canApplyAura, isBossDebuff = 5, 'Magic', 0, 60, 'player', nil, nil, nil, nil else @@ -507,8 +492,9 @@ local UpdateIconAuras = function(self, cache, unit, index, filter, visible, isFr if(name) then local show = true - if(not self.forceShow) then - show = (self.CustomFilter or genericFilter) (self, false, unit, name, rank, texture, count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff) + local isPlayer = (caster and (caster == "player" or caster == "vehicle")) or false; + if(self.CustomFilter and (not self.forceShow)) then + show = self:CustomFilter(isEnemy, isPlayer, name, spellID, debuffType, duration, shouldConsolidate) end if(show) then @@ -536,7 +522,7 @@ local UpdateIconAuras = function(self, cache, unit, index, filter, visible, isFr this.icon:SetTexture(texture) this.count:SetText((count > 1 and count)) - + this:Show() --SORTING CACHE @@ -560,7 +546,7 @@ local UpdateIconAuras = function(self, cache, unit, index, filter, visible, isFr if(isDebuff) then local color = DebuffTypeColor[debuffType] or DebuffTypeColor.none - if((not isFriend) and caster and (caster ~= "player") and (caster ~= "vehicle")) then + if((isEnemy) and (not isPlayer)) then this:SetBackdropBorderColor(0.9, 0.1, 0.1, 1) this.bg:SetBackdropColor(1, 0, 0, 1) this.icon:SetDesaturated((unit and not unit:find('arena%d')) and true or false) @@ -579,17 +565,17 @@ local UpdateIconAuras = function(self, cache, unit, index, filter, visible, isFr this.overlay:Hide() end else - if((isStealable) and (not isFriend)) then + if((isStealable) and (isEnemy)) then this:SetBackdropBorderColor(0.92, 0.91, 0.55, 1) this.bg:SetBackdropColor(1, 1, 0.5, 1) this.bg:SetBackdropBorderColor(0, 0, 0, 1) else this:SetBackdropBorderColor(0, 0, 0, 1) this.bg:SetBackdropColor(0, 0, 0, 0) - this.bg:SetBackdropBorderColor(0, 0, 0, 0) - end + this.bg:SetBackdropBorderColor(0, 0, 0, 0) + end end - + if(noTime) then this:SetScript('OnUpdate', nil) this.text:SetText('') @@ -601,7 +587,7 @@ local UpdateIconAuras = function(self, cache, unit, index, filter, visible, isFr this:SetScript('OnUpdate', AuraIcon_OnUpdate) end end - + return VISIBLE else return HIDDEN @@ -609,7 +595,7 @@ local UpdateIconAuras = function(self, cache, unit, index, filter, visible, isFr end end -local UpdateBarAuras = function(self, cache, unit, index, filter, visible, isFriend) +local UpdateBarAuras = function(self, cache, unit, index, filter, visible, isEnemy) if not unit then return; end local isDebuff = filter == DEBUFF_FILTER local timeNow = GetTime() @@ -618,15 +604,16 @@ local UpdateBarAuras = function(self, cache, unit, index, filter, visible, isFri local name, rank, texture, count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff = UnitAura(unit, index, filter); if(self.forceShow) then - spellID = 47540 + spellID = DEMO_SPELLS[random(1, #DEMO_SPELLS)]; name, rank, texture = GetSpellInfo(spellID) count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, canApplyAura, isBossDebuff = 5, 'Magic', 0, 60, 'player', nil, nil, nil, nil end if(name) then local show = true - if(not self.forceShow) then - show = (self.CustomFilter or genericFilter) (self, false, unit, name, rank, texture, count, debuffType, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID, canApplyAura, isBossDebuff) + local isPlayer = (caster and (caster == "player" or caster == "vehicle")) or false; + if((not self.forceShow) and self.CustomFilter) then + show = self:CustomFilter(isEnemy, isPlayer, name, spellID, debuffType, duration, shouldConsolidate) end if(show) then @@ -654,7 +641,7 @@ local UpdateBarAuras = function(self, cache, unit, index, filter, visible, isFri this.icon:SetTexture(texture) this.count:SetText((count > 1 and count)) - + this:Show() --SORTING CACHE @@ -686,7 +673,7 @@ local UpdateBarAuras = function(self, cache, unit, index, filter, visible, isFri else bar:SetStatusBarColor(.2, .6, 1) end - + return VISIBLE else return HIDDEN @@ -700,11 +687,11 @@ local ParseIconAuras = function(self, unit) local index = 1; local visible = 0; local cache = {}; - local isFriend = (UnitIsFriend('player', unit) == 1) and true or false; + local isEnemy = UnitIsEnemy('player', unit); while(visible < limit) do if(self.forceShow and visible > 8) then break end - local result = UpdateIconAuras(self, cache, unit, index, filter, visible, isFriend) + local result = UpdateIconAuras(self, cache, unit, index, filter, visible, isEnemy) if(not result) then break elseif(result == VISIBLE) then @@ -728,12 +715,11 @@ local ParseBarAuras = function(self, unit) local index = 1; local visible = 0; local cache = {}; - - local isFriend = (UnitIsFriend('player', unit) == 1) and true or false; + local isEnemy = UnitIsEnemy('player', unit); while(visible < limit) do if(self.forceShow and visible > 8) then break end - local result = UpdateBarAuras(self, cache, unit, index, filter, visible, isFriend) + local result = UpdateBarAuras(self, cache, unit, index, filter, visible, isEnemy) if(not result) then break elseif(result == VISIBLE) then @@ -836,7 +822,7 @@ local Enable = function(self) debuffs.Icons = debuffs.Icons or CreateFrame("Frame", nil, debuffs) debuffs.Icons:SetAllPoints(debuffs) - + if(barsAvailable) then debuffs.spark = true; debuffs.UseBars = false; @@ -863,4 +849,4 @@ local Disable = function(self) end end -oUF:AddElement('Auras', Update, Enable, Disable) \ No newline at end of file +oUF:AddElement('Auras', Update, Enable, Disable)