--[[ ############################################################################## _____/\\\\\\\\\\\____/\\\________/\\\__/\\\________/\\\__/\\\\\\\\\\\_ # ___/\\\/////////\\\_\/\\\_______\/\\\_\/\\\_______\/\\\_\/////\\\///__ # __\//\\\______\///__\//\\\______/\\\__\/\\\_______\/\\\_____\/\\\_____ # ___\////\\\__________\//\\\____/\\\___\/\\\_______\/\\\_____\/\\\_____ # ______\////\\\________\//\\\__/\\\____\/\\\_______\/\\\_____\/\\\_____ # _________\////\\\______\//\\\/\\\_____\/\\\_______\/\\\_____\/\\\_____ # __/\\\______\//\\\______\//\\\\\______\//\\\______/\\\______\/\\\_____ # _\///\\\\\\\\\\\/________\//\\\________\///\\\\\\\\\/____/\\\\\\\\\\\_# ___\///////////___________\///___________\/////////_____\///////////_# ############################################################################## S U P E R - V I L L A I N - U I By: Munglunch # ############################################################################## ########################################################## LOCALIZED LUA FUNCTIONS ########################################################## ]]-- --LUA local unpack = unpack; local select = select; local pairs = pairs; local type = type; local rawset = rawset; local rawget = rawget; local tostring = tostring; local error = error; local next = next; local pcall = pcall; local getmetatable = getmetatable; local setmetatable = setmetatable; local assert = assert; --BLIZZARD local _G = _G; local tinsert = _G.tinsert; local tremove = _G.tremove; local twipe = _G.wipe; --STRING local string = string; local format = string.format; local find = string.find; local match = string.match; --MATH local math = math; local min, random = math.min, math.random; --TABLE local table = table; --[[ LOCALIZED BLIZZ FUNCTIONS ]]-- local NewHook = hooksecurefunc; --[[ ########################################################## GET ADDON DATA AND TEST FOR oUF ########################################################## ]]-- local SV = select(2, ...) local oUF_Villain = SV.oUF assert(oUF_Villain, "SVUI was unable to locate oUF.") local L = SV.L; local MOD = SV.SVUnit --[[ ########################################################## LOCALS ########################################################## ]]-- local _PRIVATE_ENVIRONMENT; local _PRIVATE_FUNCTIONS = {}; local _PRIVATE_TAGS = {}; local _PRIVATE_METHODS = { UnitPower = function(unit, g) if unit:find('target') or unit:find('focus') then return UnitPower(unit, g) end return random(1, UnitPowerMax(unit, g)or 1) end, UnitHealth = function(unit) if unit:find('target') or unit:find('focus') then return UnitHealth(unit) end return random(1, UnitHealthMax(unit)) end, UnitName = function(unit) if unit:find('target') or unit:find('focus') then return UnitName(unit) end return "Dummy" end, UnitClass = function(unit) if unit:find('target') or unit:find('focus') then return UnitClass(unit) end local token = CLASS_SORT_ORDER[random(1, #(CLASS_SORT_ORDER))] return LOCALIZED_CLASS_NAMES_MALE[token], token end, Hex = function(r, g, b) if not r then return end if type(r) == "table" then if r.r then r, g, b = r.r, r.g, r.b else r, g, b = unpack(r) end end return ("|cff%02x%02x%02x"):format(r * 255, g * 255, b * 255) end, ColorGradient = oUF_Villain.ColorGradient, }; local AttributeChangeHook = function(self) if not self:GetParent().forceShow and not self.forceShow then return end if not self:IsShown() then return end local key = self.___groupkey local db = SV.db.SVUnit[key] local newIndex = -4; if self:GetAttribute("startingIndex") ~= newIndex then self:SetAttribute("startingIndex", newIndex) self.isForced = true; self:EnableChildren() end end; local function SetProxyEnv() if(_PRIVATE_ENVIRONMENT ~= nil) then return end _PRIVATE_ENVIRONMENT = setmetatable(_PRIVATE_METHODS, { __index = _G, __newindex = function(_,key,value) _G[key] = value end }); for i=1, 30 do _PRIVATE_TAGS['name:'..i] = oUF_Villain.Tags.Methods['name:'..i] end _PRIVATE_TAGS['name:color'] = oUF_Villain.Tags.Methods['name:color'] _PRIVATE_TAGS['name:grid'] = oUF_Villain.Tags.Methods['name:grid'] _PRIVATE_TAGS['health:color'] = oUF_Villain.Tags.Methods['health:color'] _PRIVATE_TAGS['health:current'] = oUF_Villain.Tags.Methods['health:current'] _PRIVATE_TAGS['health:deficit'] = oUF_Villain.Tags.Methods['health:deficit'] _PRIVATE_TAGS['health:curpercent'] = oUF_Villain.Tags.Methods['health:curpercent'] _PRIVATE_TAGS['health:curmax'] = oUF_Villain.Tags.Methods['health:curmax'] _PRIVATE_TAGS['health:curmax-percent'] = oUF_Villain.Tags.Methods['health:curmax-percent'] _PRIVATE_TAGS['health:max'] = oUF_Villain.Tags.Methods['health:max'] _PRIVATE_TAGS['health:percent'] = oUF_Villain.Tags.Methods['health:percent'] _PRIVATE_TAGS['power:color'] = oUF_Villain.Tags.Methods['power:color'] _PRIVATE_TAGS['power:current'] = oUF_Villain.Tags.Methods['power:current'] _PRIVATE_TAGS['power:deficit'] = oUF_Villain.Tags.Methods['power:deficit'] _PRIVATE_TAGS['power:curpercent'] = oUF_Villain.Tags.Methods['power:curpercent'] _PRIVATE_TAGS['power:curmax'] = oUF_Villain.Tags.Methods['power:curmax'] _PRIVATE_TAGS['power:curmax-percent'] = oUF_Villain.Tags.Methods['power:curmax-percent'] _PRIVATE_TAGS['power:max'] = oUF_Villain.Tags.Methods['power:max'] _PRIVATE_TAGS['power:percent'] = oUF_Villain.Tags.Methods['power:percent'] end function MOD:ViewEnemyFrames(unit, numGroup) if InCombatLockdown()then return end for i=1, numGroup do local unitName = unit..i local frame = self.Units[unitName] if(frame and frame.Allow) then if(not frame.isForced) then frame:Allow() else frame:Restrict() end end end end function MOD:ViewGroupFrames(headerFrame, setForced) if InCombatLockdown() then return end if(not headerFrame) then return end SetProxyEnv() headerFrame.forceShow = setForced; headerFrame.forceShowAuras = setForced; headerFrame.isForced = setForced; local raidToken = headerFrame.___groupkey if setForced then for _, func in pairs(_PRIVATE_TAGS) do if type(func) == "function" then if(not _PRIVATE_FUNCTIONS[func]) then _PRIVATE_FUNCTIONS[func] = getfenv(func) setfenv(func, _PRIVATE_ENVIRONMENT) end end end RegisterStateDriver(headerFrame, "visibility", "show") else for func, fenv in pairs(_PRIVATE_FUNCTIONS)do setfenv(func, fenv) _PRIVATE_FUNCTIONS[func] = nil end local db = SV.db.SVUnit[raidToken] RegisterStateDriver(headerFrame, "visibility", db.visibility) local eventScript = headerFrame:GetScript("OnEvent") if eventScript then eventScript(headerFrame, "PLAYER_ENTERING_WORLD") end end for i = 1, #headerFrame.groups do local groupFrame = headerFrame.groups[i] if(groupFrame:IsShown()) then groupFrame.forceShow = headerFrame.forceShow; groupFrame.forceShowAuras = headerFrame.forceShowAuras; groupFrame:HookScript("OnAttributeChanged", AttributeChangeHook) if setForced then groupFrame:SetAttribute("showRaid", nil) groupFrame:SetAttribute("showParty", nil) groupFrame:SetAttribute("showSolo", nil) AttributeChangeHook(groupFrame) groupFrame:Update() else groupFrame:SetAttribute("showRaid", true) groupFrame:SetAttribute("showParty", true) groupFrame:SetAttribute("showSolo", true) groupFrame:DisableChildren() groupFrame:SetAttribute("startingIndex", 1) groupFrame:Update() end end end headerFrame:SetVisibility() collectgarbage("collect") end