--[[ ############################################################################## _____/\\\\\\\\\\\____/\\\________/\\\__/\\\________/\\\__/\\\\\\\\\\\_ # ___/\\\/////////\\\_\/\\\_______\/\\\_\/\\\_______\/\\\_\/////\\\///__ # __\//\\\______\///__\//\\\______/\\\__\/\\\_______\/\\\_____\/\\\_____ # ___\////\\\__________\//\\\____/\\\___\/\\\_______\/\\\_____\/\\\_____ # ______\////\\\________\//\\\__/\\\____\/\\\_______\/\\\_____\/\\\_____ # _________\////\\\______\//\\\/\\\_____\/\\\_______\/\\\_____\/\\\_____ # __/\\\______\//\\\______\//\\\\\______\//\\\______/\\\______\/\\\_____ # _\///\\\\\\\\\\\/________\//\\\________\///\\\\\\\\\/____/\\\\\\\\\\\_# ___\///////////___________\///___________\/////////_____\///////////_# ############################################################################## S U P E R - V I L L A I N - U I By: Munglunch # ############################################################################## ########################################################## LOCALIZED LUA FUNCTIONS ########################################################## ]]-- --[[ GLOBALS ]]-- local _G = _G; local unpack = _G.unpack; local select = _G.select; local pairs = _G.pairs; local ipairs = _G.ipairs; local type = _G.type; local tinsert = _G.tinsert; local string = _G.string; local math = _G.math; local table = _G.table; --[[ STRING METHODS ]]-- local find, format, len, split = string.find, string.format, string.len, string.split; local gmatch, gsub, join = string.gmatch, string.gsub, string.join; --[[ MATH METHODS ]]-- local abs, ceil, floor, round, min = math.abs, math.ceil, math.floor, math.round, math.min; --[[ TABLE METHODS ]]-- local twipe = table.wipe; --[[ ########################################################## GET ADDON DATA ########################################################## ]]-- local SuperVillain, L = unpack(select(2, ...)); local MOD = SuperVillain.Registry:Expose('SVUnit'); local _, ns = ... local oUF_SuperVillain = ns.oUF --[[ MUNGLUNCH's FASTER ASSERT FUNCTION ]]-- local assert = enforce; assert(oUF_SuperVillain, "SVUI was unable to locate oUF.") local LSM = LibStub("LibSharedMedia-3.0"); --[[ ########################################################## LOCAL VARS ########################################################## ]]-- local CURRENT_BAR_TEXTURE = [[Interface\AddOns\SVUI\assets\artwork\Bars\DEFAULT]]; local CURRENT_AURABAR_TEXTURE = [[Interface\AddOns\SVUI\assets\artwork\Bars\GLOWING]]; local CURRENT_FONT = [[Interface\AddOns\SVUI\assets\fonts\Names.ttf]]; local CURRENT_FONTSIZE = 10; local CURRENT_FONTOUTLINE = "OUTLINE"; local CURRENT_AURABAR_FONT = [[Interface\AddOns\SVUI\assets\fonts\Alert.ttf]]; local CURRENT_AURABAR_FONTSIZE = 14 local CURRENT_AURABAR_FONTOUTLINE = "NONE" local INIT_UPDATE = false; --[[ ########################################################## CORE FUNCTIONS ########################################################## ]]-- local function UpdateUnitMediaLocals() CURRENT_BAR_TEXTURE = LSM:Fetch("statusbar", MOD.db.statusbar) CURRENT_AURABAR_TEXTURE = LSM:Fetch("statusbar", MOD.db.auraBarStatusbar); CURRENT_FONT = LSM:Fetch("font", MOD.db.font) CURRENT_FONTSIZE = MOD.db.fontSize CURRENT_FONTOUTLINE = MOD.db.fontOutline CURRENT_AURABAR_FONT = LSM:Fetch("font", MOD.db.auraFont); CURRENT_AURABAR_FONTSIZE = MOD.db.auraFontSize CURRENT_AURABAR_FONTOUTLINE = MOD.db.auraFontOutline INIT_UPDATE = true end function MOD:RefreshUnitColors() local db = SuperVillain.db.media.unitframes for i, setting in pairs(db) do if setting and type(setting) == "table" then if(setting[1]) then oUF_SuperVillain.colors[i] = setting else local bt = {} for x, color in pairs(setting) do if(color)then bt[x] = color end oUF_SuperVillain.colors[i] = bt end end elseif setting then oUF_SuperVillain.colors[i] = setting end end local r, g, b = db.health[1], db.health[2], db.health[3] oUF_SuperVillain.colors.smooth = {1, 0, 0, 1, 1, 0, r, g, b} end local unitRoster = {"player", "target", "targettarget", "pet", "pettarget", "focus", "focustarget", "party", "raidpet", "assist", "tank", "raid10", "raid25", "raid40", "boss", "arena"}; function MOD:RefreshUnitMedia(unitName, updateUpvalues) if(not self.db or (self.db and self.db.enable ~= true)) then return end if((not INIT_UPDATE) or updateUpvalues == true) then UpdateUnitMediaLocals() end local db = self.db local unitDB = db[unitName] if(self[unitName] and unitDB and unitDB.enable) then local frame = self[unitName] local panel = frame.InfoPanel if(panel) then if(panel.Name and unitDB.name) then panel.Name:SetFont(LSM:Fetch("font", unitDB.name.font), unitDB.name.fontSize, unitDB.name.fontOutline) end if(panel.Health) then panel.Health:SetFont(CURRENT_FONT, CURRENT_FONTSIZE, CURRENT_FONTOUTLINE) end if(panel.Power) then panel.Power:SetFont(CURRENT_FONT, CURRENT_FONTSIZE, CURRENT_FONTOUTLINE) end if(panel.Misc) then panel.Misc:SetFont(CURRENT_FONT, CURRENT_FONTSIZE, CURRENT_FONTOUTLINE) end end if(frame.Power and (unitDB.power and unitDB.power.enable)) then frame.Power:SetStatusBarTexture(CURRENT_BAR_TEXTURE) end if(frame.AuraBars and (unitDB.aurabar and unitDB.aurabar.enable)) then local ab = frame.AuraBars ab.auraBarTexture = CURRENT_AURABAR_TEXTURE ab.textFont = CURRENT_AURABAR_FONT ab.textSize = CURRENT_AURABAR_FONTSIZE ab.textOutline = CURRENT_AURABAR_FONTOUTLINE end if(frame.Buffs and (unitDB.buffs and unitDB.buffs.enable)) then local buffs = frame.Buffs buffs.textFont = CURRENT_AURABAR_FONT buffs.textSize = CURRENT_AURABAR_FONTSIZE buffs.textOutline = CURRENT_AURABAR_FONTOUTLINE end if(frame.Debuffs and (unitDB.debuffs and unitDB.debuffs.enable)) then local debuffs = frame.Debuffs debuffs.textFont = CURRENT_AURABAR_FONT debuffs.textSize = CURRENT_AURABAR_FONTSIZE debuffs.textOutline = CURRENT_AURABAR_FONTOUTLINE end end end function MOD:RefreshAllUnitMedia() if(not self.db or (self.db and self.db.enable ~= true)) then return end UpdateUnitMediaLocals() -- [[ COLORS ]] -- self:RefreshUnitColors() -- [[ FRAMES ]] -- for i = 1, 16 do self:RefreshUnitMedia(unitRoster[i], false) end end