/ShadowedUF_Options/config.lua
Lua | 5514 lines | 5166 code | 262 blank | 86 comment | 417 complexity | e0dc3a3ceaf3b153276e4af0caeaa599 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- local Config = {}
- local AceDialog, AceRegistry, AceGUI, SML, registered, options
- local playerClass = select(2, UnitClass("player"))
- local modifyUnits, globalConfig = {}, {}
- local L = ShadowUF.L
-
- ShadowUF.Config = Config
-
- --[[
- The part that makes configuration a pain when you actually try is it gets unwieldly when you're adding special code to deal with
- showing help for certain cases, swapping tabs etc that makes it work smoothly.
-
- I'm going to have to split it out into separate files for each type to clean everything up but that takes time and I have other things
- I want to get done with first.
- ]]
-
- local unitCategories = {
- player = {"player", "pet"},
- general = {"target", "targettarget", "targettargettarget", "focus", "focustarget", "pettarget"},
- party = {"party", "partypet", "partytarget"},
- raid = {"raid", "raidpet", "boss", "bosstarget", "maintank", "maintanktarget", "mainassist", "mainassisttarget"},
- arena = {"arena", "arenapet", "arenatarget"}}
-
- local UNIT_DESC = {
- ["boss"] = L["Boss units are for only certain fights, such as Blood Princes or the Gunship battle, you will not see them for every boss fight."],
- ["mainassist"] = L["Main Assists's are set by the Blizzard Main Assist system or mods that use them such as oRA3."],
- ["maintank"] = L["Main Tank's are set by the Blizzard Main Tank system or mods that use them such as oRA3."],
- }
-
- local PAGE_DESC = {
- ["general"] = L["General configuration to all enabled units."],
- ["enableUnits"] = L["Various units can be enabled through this page, such as raid or party targets."],
- ["hideBlizzard"] = L["Hiding and showing various aspects of the default UI such as the player buff frames."],
- ["units"] = L["Configuration to specific unit frames."],
- ["visibility"] = L["Disabling unit modules in various instances."],
- ["tags"] = L["Advanced tag management, allows you to add your own custom tags."],
- ["filter"] = L["Simple aura filtering by whitelists and blacklists."],
- }
- local INDICATOR_NAMES = {["leader"] = L["Leader"], ["lfdRole"] = L["Dungeon role"], ["masterLoot"] = L["Master looter"], ["pvp"] = L["PvP Flag"], ["raidTarget"] = L["Raid target"], ["ready"] = L["Ready status"], ["role"] = L["Raid role"], ["status"] = L["Combat status"], ["class"] = L["Class icon"], ["resurrect"] = L["Resurrect status"], ["phase"] = L["Phase status"]}
- local AREA_NAMES = {["arena"] = L["Arenas"],["none"] = L["Everywhere else"], ["party"] = L["Party instances"], ["pvp"] = L["Battlegrounds"], ["raid"] = L["Raid instances"]}
- local INDICATOR_DESC = {
- ["leader"] = L["Crown indicator for group leaders."], ["lfdRole"] = L["Role the unit is playing in dungeons formed through the Looking For Dungeon system."],
- ["masterLoot"] = L["Bag indicator for master looters."], ["pvp"] = L["PVP flag indicator, Horde for Horde flagged pvpers and Alliance for Alliance flagged pvpers."],
- ["raidTarget"] = L["Raid target indicator."], ["ready"] = L["Ready status of group members."],
- ["role"] = L["Raid role indicator, adds a shield indicator for main tanks and a sword icon for main assists."], ["status"] = L["Status indicator, shows if the unit is currently in combat. For the player it will also show if you are rested."], ["class"] = L["Class icon for players."]}
- local TAG_GROUPS = {["classification"] = L["Classifications"], ["health"] = L["Health"], ["misc"] = L["Miscellaneous"], ["playerthreat"] = L["Player threat"], ["power"] = L["Power"], ["status"] = L["Status"], ["threat"] = L["Threat"], ["raid"] = L["Raid"], ["absorb"] = L["Absorb"]}
-
- local pointPositions = {["BOTTOM"] = L["Bottom"], ["TOP"] = L["Top"], ["LEFT"] = L["Left"], ["RIGHT"] = L["Right"], ["TOPLEFT"] = L["Top Left"], ["TOPRIGHT"] = L["Top Right"], ["BOTTOMLEFT"] = L["Bottom Left"], ["BOTTOMRIGHT"] = L["Bottom Right"], ["CENTER"] = L["Center"]}
- local positionList = {["C"] = L["Center"], ["RT"] = L["Right Top"], ["RC"] = L["Right Center"], ["RB"] = L["Right Bottom"], ["LT"] = L["Left Top"], ["LC"] = L["Left Center"], ["LB"] = L["Left Bottom"], ["BL"] = L["Bottom Left"], ["BC"] = L["Bottom Center"], ["BR"] = L["Bottom Right"], ["TR"] = L["Top Right"], ["TC"] = L["Top Center"], ["TL"] = L["Top Left"]}
-
- local unitOrder = {}
- for order, unit in pairs(ShadowUF.unitList) do unitOrder[unit] = order end
- local fullReload = {["bars"] = true, ["auras"] = true, ["backdrop"] = true, ["font"] = true, ["classColors"] = true, ["powerColors"] = true, ["healthColors"] = true, ["xpColors"] = true, ["omnicc"] = true}
- local quickIDMap = {}
-
- -- Helper functions
- local function getPageDescription(info)
- return PAGE_DESC[info[#(info)]]
- end
-
- local function getFrameName(unit)
- if( unit == "raidpet" or unit == "raid" or unit == "party" or unit == "maintank" or unit == "mainassist" or unit == "boss" or unit == "arena" ) then
- return string.format("#SUFHeader%s", unit)
- end
-
- return string.format("#SUFUnit%s", unit)
- end
-
- local anchorList = {}
- local function getAnchorParents(info)
- local unit = info[2]
- for k in pairs(anchorList) do anchorList[k] = nil end
-
- if( ShadowUF.Units.childUnits[unit] ) then
- anchorList["$parent"] = string.format(L["%s member"], L.units[ShadowUF.Units.childUnits[unit]])
- return anchorList
- end
-
- anchorList["UIParent"] = L["Screen"]
-
- -- Don't let a frame anchor to a frame thats anchored to it already (Stop infinite loops-o-doom)
- local currentName = getFrameName(unit)
- for _, unitID in pairs(ShadowUF.unitList) do
- if( unitID ~= unit and ShadowUF.db.profile.positions[unitID] and ShadowUF.db.profile.positions[unitID].anchorTo ~= currentName ) then
- anchorList[getFrameName(unitID)] = string.format(L["%s frames"], L.units[unitID] or unitID)
- end
- end
-
- return anchorList
- end
-
- local function selectDialogGroup(group, key)
- AceDialog.Status.ShadowedUF.children[group].status.groups.selected = key
- AceRegistry:NotifyChange("ShadowedUF")
- end
-
- local function selectTabGroup(group, subGroup, key)
- AceDialog.Status.ShadowedUF.children[group].status.groups.selected = subGroup
- AceDialog.Status.ShadowedUF.children[group].children[subGroup].status.groups.selected = key
- AceRegistry:NotifyChange("ShadowedUF")
- end
-
- local function hideAdvancedOption(info)
- return not ShadowUF.db.profile.advanced
- end
-
- local function hideBasicOption(info)
- return ShadowUF.db.profile.advanced
- end
-
- local function isUnitDisabled(info)
- local unit = info[#(info)]
- local enabled = ShadowUF.db.profile.units[unit].enabled
- for _, visibility in pairs(ShadowUF.db.profile.visibility) do
- if( visibility[unit] ) then
- enabled = visibility[unit]
- break
- end
- end
-
- return not enabled
- end
-
- local function mergeTables(parent, child)
- for key, value in pairs(child) do
- if( type(parent[key]) == "table" ) then
- parent[key] = mergeTables(parent[key], value)
- elseif( type(value) == "table" ) then
- parent[key] = CopyTable(value)
- elseif( parent[key] == nil ) then
- parent[key] = value
- end
- end
-
- return parent
- end
-
- local function getName(info)
- local key = info[#(info)]
- if( ShadowUF.modules[key] and ShadowUF.modules[key].moduleName ) then
- return ShadowUF.modules[key].moduleName
- end
-
- return LOCALIZED_CLASS_NAMES_MALE[key] or INDICATOR_NAMES[key] or L.units[key] or TAG_GROUPS[key] or L[key]
- end
-
- local function getUnitOrder(info)
- return unitOrder[info[#(info)]]
- end
-
- local function isModifiersSet(info)
- if( info[2] ~= "global" ) then return false end
- for k in pairs(modifyUnits) do return false end
- return true
- end
-
- -- These are for setting simple options like bars.texture = "Default" or locked = true
- local function set(info, value)
- local cat, key = string.split(".", info.arg)
- if( key == "$key" ) then key = info[#(info)] end
-
- if( not key ) then
- ShadowUF.db.profile[cat] = value
- else
- ShadowUF.db.profile[cat][key] = value
- end
-
- if( cat and fullReload[cat] ) then
- ShadowUF.Layout:CheckMedia()
- ShadowUF.Layout:Reload()
- end
- end
-
- local function get(info)
- local cat, key = string.split(".", info.arg)
- if( key == "$key" ) then key = info[#(info)] end
- if( not key ) then
- return ShadowUF.db.profile[cat]
- else
- return ShadowUF.db.profile[cat][key]
- end
- end
-
- local function setColor(info, r, g, b, a)
- local color = get(info)
- color.r, color.g, color.b, color.a = r, g, b, a
- set(info, color)
- end
-
- local function getColor(info)
- local color = get(info)
- return color.r, color.g, color.b, color.a
- end
-
- -- These are for setting complex options like units.player.auras.buffs.enabled = true or units.player.portrait.enabled = true
- local function setVariable(unit, moduleKey, moduleSubKey, key, value)
- local configTable = unit == "global" and globalConfig or ShadowUF.db.profile.units[unit]
-
- -- For setting options like units.player.auras.buffs.enabled = true
- if( moduleKey and moduleSubKey and configTable[moduleKey][moduleSubKey] ) then
- configTable[moduleKey][moduleSubKey][key] = value
- ShadowUF.Layout:Reload(unit)
- -- For setting options like units.player.portrait.enabled = true
- elseif( moduleKey and not moduleSubKey and configTable[moduleKey] ) then
- configTable[moduleKey][key] = value
- ShadowUF.Layout:Reload(unit)
- -- For setting options like units.player.height = 50
- elseif( not moduleKey and not moduleSubKey ) then
- configTable[key] = value
- ShadowUF.Layout:Reload(unit)
- end
- end
-
- local function specialRestricted(unit, moduleKey, moduleSubKey, key)
- if( ShadowUF.fakeUnits[unit] and ( key == "colorAggro" or key == "aggro" or moduleKey == "incHeal" or moduleKey == "castBar" ) ) then
- return true
- elseif( moduleKey == "healthBar" and unit == "player" and key == "reaction" ) then
- return true
- end
- end
-
- local function setDirectUnit(unit, moduleKey, moduleSubKey, key, value)
- if( unit == "global" ) then
- for unit in pairs(modifyUnits) do
- if( not specialRestricted(unit, moduleKey, moduleSubKey, key) ) then
- setVariable(unit, moduleKey, moduleSubKey, key, value)
- end
- end
-
- setVariable("global", moduleKey, moduleSubKey, key, value)
- else
- setVariable(unit, moduleKey, moduleSubKey, key, value)
- end
- end
-
- local function setUnit(info, value)
- local unit = info[2]
- -- auras, buffs, enabled / text, 1, text / portrait, enabled
- local moduleKey, moduleSubKey, key = string.split(".", info.arg)
- if( not moduleSubKey ) then key = moduleKey moduleKey = nil end
- if( moduleSubKey and not key ) then key = moduleSubKey moduleSubKey = nil end
- if( moduleSubKey == "$parent" ) then moduleSubKey = info[#(info) - 1] end
- if( moduleKey == "$parent" ) then moduleKey = info[#(info) - 1] end
- if( tonumber(moduleSubKey) ) then moduleSubKey = tonumber(moduleSubKey) end
-
- setDirectUnit(unit, moduleKey, moduleSubKey, key, value)
- end
-
- local function getVariable(unit, moduleKey, moduleSubKey, key)
- local configTbl = unit == "global" and globalConfig or ShadowUF.db.profile.units[unit]
- if( moduleKey and moduleSubKey ) then
- return configTbl[moduleKey][moduleSubKey] and configTbl[moduleKey][moduleSubKey][key]
- elseif( moduleKey and not moduleSubKey ) then
- return configTbl[moduleKey] and configTbl[moduleKey][key]
- end
-
- return configTbl[key]
- end
-
- local function getUnit(info)
- local moduleKey, moduleSubKey, key = string.split(".", info.arg)
- if( not moduleSubKey ) then key = moduleKey moduleKey = nil end
- if( moduleSubKey and not key ) then key = moduleSubKey moduleSubKey = nil end
- if( moduleSubKey == "$parent" ) then moduleSubKey = info[#(info) - 1] end
- if( moduleKey == "$parent" ) then moduleKey = info[#(info) - 1] end
- if( tonumber(moduleSubKey) ) then moduleSubKey = tonumber(moduleSubKey) end
-
- return getVariable(info[2], moduleKey, moduleSubKey, key)
- end
-
- -- Tag functions
- local function getTagName(info)
- local tag = info[#(info)]
- if( ShadowUF.db.profile.tags[tag] and ShadowUF.db.profile.tags[tag].name ) then
- return ShadowUF.db.profile.tags[tag].name
- end
-
- return ShadowUF.Tags.defaultNames[tag] or tag
- end
-
- local function getTagHelp(info)
- local tag = info[#(info)]
- return ShadowUF.Tags.defaultHelp[tag] or ShadowUF.db.profile.tags[tag] and ShadowUF.db.profile.tags[tag].help
- end
-
- -- Module functions
- local function hideRestrictedOption(info)
- local unit = type(info.arg) == "number" and info[#(info) - info.arg] or info[2]
- local key = info[#(info)]
- if( ShadowUF.modules[key] and ShadowUF.modules[key].moduleClass and ShadowUF.modules[key].moduleClass ~= playerClass ) then
- return true
- elseif( key == "incHeal" and not ShadowUF.modules.incHeal ) then
- return true
- -- Non-standard units do not support color by aggro or incoming heal
- elseif( key == "colorAggro" or key == "incHeal" or key == "aggro" ) then
- return string.match(unit, "%w+target" )
- -- Fall back for indicators, no variable table so it shouldn't be shown
- elseif( info[#(info) - 1] == "indicators" ) then
- if( ( unit == "global" and not globalConfig.indicators[key] ) or ( unit ~= "global" and not ShadowUF.db.profile.units[unit].indicators[key] ) ) then
- return true
- end
- -- Fall back, no variable table so it shouldn't be shown
- elseif( ( unit == "global" and not globalConfig[key] ) or ( unit ~= "global" and not ShadowUF.db.profile.units[unit][key] ) ) then
- return true
- end
-
- return false
- end
-
- local function getModuleOrder(info)
- local key = info[#(info)]
- return key == "healthBar" and 1 or key == "powerBar" and 2 or key == "castBar" and 3 or 4
- end
-
- -- Expose these for modules
- Config.getAnchorParents = getAnchorParents
- Config.hideAdvancedOption = hideAdvancedOption
- Config.isUnitDisabled = isUnitDisabled
- Config.selectDialogGroup = selectDialogGroup
- Config.selectTabGroup = selectTabGroup
- Config.getName = getName
- Config.getUnitOrder = getUnitOrder
- Config.isModifiersSet = isModifiersSet
- Config.set = set
- Config.get = get
- Config.setUnit = setUnit
- Config.setVariable = setVariable
- Config.getUnit = getUnit
- Config.getVariable = getVariable
- Config.hideRestrictedOption = hideRestrictedOption
- Config.hideBasicOption = hideBasicOption
-
-
- --------------------
- -- GENERAL CONFIGURATION
- ---------------------
- local function loadGeneralOptions()
- SML = SML or LibStub:GetLibrary("LibSharedMedia-3.0")
-
- local MediaList = {}
- local function getMediaData(info)
- local mediaType = info[#(info)]
-
- MediaList[mediaType] = MediaList[mediaType] or {}
-
- for k in pairs(MediaList[mediaType]) do MediaList[mediaType][k] = nil end
- for _, name in pairs(SML:List(mediaType)) do
- MediaList[mediaType][name] = name
- end
-
- return MediaList[mediaType]
- end
-
-
- local barModules = {}
- for key, module in pairs(ShadowUF.modules) do
- if( module.moduleHasBar ) then
- barModules["$" .. key] = module.moduleName
- end
- end
-
- local addTextParent = {
- order = 4,
- type = "group",
- inline = true,
- name = function(info) return barModules[info[#(info)]] or string.sub(info[#(info)], 2) end,
- hidden = function(info)
- for _, text in pairs(ShadowUF.db.profile.units.player.text) do
- if( text.anchorTo == info[#(info)] ) then
- return false
- end
- end
-
- return true
- end,
- args = {},
- }
-
- local addTextLabel = {
- order = function(info) return tonumber(string.match(info[#(info)], "(%d+)")) end,
- type = "description",
- width = "",
- fontSize = "medium",
- hidden = function(info)
- local id = tonumber(string.match(info[#(info)], "(%d+)"))
- if( not getVariable("player", "text", nil, id) ) then return true end
- return getVariable("player", "text", id, "anchorTo") ~= info[#(info) - 1]
- end,
- name = function(info)
- return getVariable("player", "text", tonumber(string.match(info[#(info)], "(%d+)")), "name")
- end,
- }
-
- local addTextSep = {
- order = function(info) return tonumber(string.match(info[#(info)], "(%d+)")) + 0.75 end,
- type = "description",
- width = "full",
- hidden = function(info)
- local id = tonumber(string.match(info[#(info)], "(%d+)"))
- if( not getVariable("player", "text", nil, id) ) then return true end
- return getVariable("player", "text", id, "anchorTo") ~= info[#(info) - 1]
- end,
- name = "",
- }
-
- local addText = {
- order = function(info) return info[#(info)] + 0.5 end,
- type = "execute",
- width = "half",
- name = L["Delete"],
- hidden = function(info)
- local id = tonumber(info[#(info)])
- if( not getVariable("player", "text", nil, id) ) then return true end
- return getVariable("player", "text", id, "anchorTo") ~= info[#(info) - 1]
- end,
- disabled = function(info) return tonumber(info[#(info)]) <= 5 end,
- confirmText = L["Are you sure you want to delete this text? All settings for it will be deleted."],
- confirm = true,
- func = function(info)
- local id = tonumber(info[#(info)])
- for _, unit in pairs(ShadowUF.unitList) do
- table.remove(ShadowUF.db.profile.units[unit].text, id)
- end
-
- addTextParent.args[info[#(info)]] = nil
- ShadowUF.Layout:Reload()
- end,
- }
-
- local function validateSpell(info, spell)
- if( spell and spell ~= "" and not GetSpellInfo(spell) ) then
- return string.format(L["Invalid spell \"%s\" entered."], spell or "")
- end
-
- return true
- end
-
- local function setRange(info, spell)
- ShadowUF.db.profile.range[info[#(info)] .. playerClass] = spell and spell ~= "" and spell or nil
- ShadowUF.Layout:Reload()
- end
-
- local function getRange(info, spell)
- local spell = ShadowUF.db.profile.range[info[#(info)] .. playerClass]
- return spell and spell ~= "" and spell or ShadowUF.modules.range[info[#(info)]][playerClass]
- end
-
- local textData = {}
-
- local function writeTable(tbl)
- local data = ""
- for key, value in pairs(tbl) do
- local valueType = type(value)
-
- -- Wrap the key in brackets if it's a number
- if( type(key) == "number" ) then
- key = string.format("[%s]", key)
- -- Wrap the string with quotes if it has a space in it
- elseif( string.match(key, "[%p%s%c]") ) then
- key = string.format("['%s']", string.gsub(key, "'", "\\'"))
- end
-
- -- foo = {bar = 5}
- if( valueType == "table" ) then
- data = string.format("%s%s=%s;", data, key, writeTable(value))
- -- foo = true / foo = 5
- elseif( valueType == "number" or valueType == "boolean" ) then
- data = string.format("%s%s=%s;", data, key, tostring(value))
- -- foo = "bar"
- else
- data = string.format("%s%s='%s';", data, key, string.gsub(tostring(value), "'", "\\'"))
- end
- end
-
- return "{" .. data .. "}"
- end
-
- local layoutData = {positions = true, visibility = true, modules = false}
- local layoutManager = {
- type = "group",
- order = 7,
- name = L["Layout manager"],
- childGroups = "tab",
- hidden = hideAdvancedOption,
- args = {
- import = {
- order = 1,
- type = "group",
- name = L["Import"],
- hidden = false,
- args = {
- help = {
- order = 1,
- type = "group",
- inline = true,
- name = function(info) return layoutData.error and L["Error"] or L["Help"] end,
- args = {
- help = {
- order = 1,
- type = "description",
- name = function(info)
- if( ShadowUF.db:GetCurrentProfile() == "Import Backup" ) then
- return L["Your active layout is the profile used for import backup, this cannot be overwritten by an import. Change your profiles to something else and try again."]
- end
-
- return layoutData.error or L["You can import another Shadowed Unit Frame users configuration by entering the export code they gave you below. This will backup your old layout to \"Import Backup\".|n|nIt will take 30-60 seconds for it to load your layout when you paste it in, please by patient."]
- end
- },
- },
- },
- positions = {
- order = 2,
- type = "toggle",
- name = L["Import unit frame positions"],
- set = function(info, value) layoutData[info[#(info)]] = value end,
- get = function(info) return layoutData[info[#(info)]] end,
- width = "double",
- },
- visibility = {
- order = 3,
- type = "toggle",
- name = L["Import visibility settings"],
- set = function(info, value) layoutData[info[#(info)]] = value end,
- get = function(info) return layoutData[info[#(info)]] end,
- width = "double",
- },
- modules = {
- order = 4,
- type = "toggle",
- name = L["Import non-standard module settings"],
- desc = L["Will not import settings of modules that are not included with Shadowed Unit Frames by default."],
- set = function(info, value) layoutData[info[#(info)]] = value end,
- get = function(info) return layoutData[info[#(info)]] end,
- width = "double",
- },
- import = {
- order = 5,
- type = "input",
- name = L["Code"],
- multiline = true,
- width = "full",
- get = false,
- disabled = function() return ShadowUF.db:GetCurrentProfile() == "Import Backup" end,
- set = function(info, import)
- local layout, err = loadstring(string.format([[return %s]], import))
- if( err ) then
- layoutData.error = string.format(L["Failed to import layout, error:|n|n%s"], err)
- return
- end
-
- layout = layout()
-
- -- Strip position settings
- if( not layoutData.positions ) then
- layout.positions = nil
- end
-
- -- Strip visibility settings
- if( not layoutData.visibility ) then
- layout.visibility = nil
- end
-
- -- Strip any units we don't have included by default
- for unit in pairs(layout.units) do
- if( not ShadowUF.defaults.profile.units[unit] ) then
- layout.units[unit] = nil
- end
- end
-
- -- Strip module settings that aren't with SUF by default
- if( not layoutData.modules ) then
- local validModules = {["healthBar"] = true, ["powerBar"] = true, ["portrait"] = true, ["range"] = true, ["text"] = true, ["indicators"] = true, ["auras"] = true, ["incHeal"] = true, ["castBar"] = true, ["combatText"] = true, ["highlight"] = true, ["runeBar"] = true, ["totemBar"] = true, ["xpBar"] = true, ["fader"] = true, ["comboPoints"] = true, ["eclipseBar"] = true, ["soulShards"] = true, ["holyPower"] = true, ["altPowerBar"] = true}
- for _, unitData in pairs(layout.units) do
- for key, data in pairs(unitData) do
- if( type(data) == "table" and not validModules[key] and ShadowUF.modules[key] ) then
- unitData[key] = nil
- end
- end
- end
- end
-
- -- Check if we need move over the visibility and positions info
- layout.positions = layout.positions or CopyTable(ShadowUF.db.profile.positions)
- layout.visibility = layout.visibility or CopyTable(ShadowUF.db.profile.positions)
-
- -- Now backup the profile
- local currentLayout = ShadowUF.db:GetCurrentProfile()
- ShadowUF.layoutImporting = true
- ShadowUF.db:SetProfile("Import Backup")
- ShadowUF.db:CopyProfile(currentLayout)
- ShadowUF.db:SetProfile(currentLayout)
- ShadowUF.db:ResetProfile()
- ShadowUF.layoutImporting = nil
-
- -- Overwrite everything we did import
- ShadowUF:LoadDefaultLayout()
- for key, data in pairs(layout) do
- if( type(data) == "table" ) then
- ShadowUF.db.profile[key] = CopyTable(data)
- else
- ShadowUF.db.profile[key] = data
- end
- end
-
- ShadowUF:ProfilesChanged()
- end,
- },
- },
- },
- export = {
- order = 2,
- type = "group",
- name = L["Export"],
- hidden = false,
- args = {
- help = {
- order = 1,
- type = "group",
- inline = true,
- name = L["Help"],
- args = {
- help = {
- order = 1,
- type = "description",
- name = L["After you hit export, you can give the below code to other Shadowed Unit Frames users and they will get your exact layout."],
- },
- },
- },
- doExport = {
- order = 2,
- type = "execute",
- name = L["Export"],
- func = function(info)
- layoutData.export = writeTable(ShadowUF.db.profile)
- end,
- },
- export = {
- order = 3,
- type = "input",
- name = L["Code"],
- multiline = true,
- width = "full",
- set = false,
- get = function(info) return layoutData[info[#(info)]] end,
- },
- },
- },
- },
- }
-
- options.args.general = {
- type = "group",
- childGroups = "tab",
- name = L["General"],
- args = {
- general = {
- type = "group",
- order = 1,
- name = L["General"],
- set = set,
- get = get,
- args = {
- general = {
- order = 1,
- type = "group",
- inline = true,
- name = L["General"],
- args = {
- locked = {
- order = 1,
- type = "toggle",
- name = L["Lock frames"],
- desc = L["Enables configuration mode, letting you move and giving you example frames to setup."],
- set = function(info, value)
- set(info, value)
- ShadowUF.modules.movers:Update()
- end,
- arg = "locked",
- },
- sep = {
- order = 1.5,
- type = "description",
- name = "",
- width = "full",
- hidden = hideAdvancedOption,
- },
- advanced = {
- order = 2,
- type = "toggle",
- name = L["Advanced"],
- desc = L["Enabling advanced settings will give you access to more configuration options. This is meant for people who want to tweak every single thing, and should not be enabled by default as it increases the options."],
- arg = "advanced",
- },
- omnicc = {
- order = 2.5,
- type = "toggle",
- name = L["Disable OmniCC"],
- desc = L["Disables showing OmniCC timers in all Shadowed Unit Frame auras."],
- arg = "omnicc",
- hidden = hideAdvancedOption,
- },
- hideCombat = {
- order = 3,
- type = "toggle",
- name = L["Hide tooltips in combat"],
- desc = L["Prevents unit tooltips from showing while in combat."],
- arg = "tooltipCombat",
- },
- auraBorder = {
- order = 5,
- type = "select",
- name = L["Aura border style"],
- desc = L["Style of borders to show for all auras."],
- values = {["dark"] = L["Dark"], ["light"] = L["Light"], ["blizzard"] = L["Blizzard"], [""] = L["None"]},
- arg = "auras.borderType",
- },
- statusbar = {
- order = 6,
- type = "select",
- name = L["Bar texture"],
- dialogControl = "LSM30_Statusbar",
- values = getMediaData,
- arg = "bars.texture",
- },
- spacing = {
- order = 7,
- type = "range",
- name = L["Bar spacing"],
- desc = L["How much spacing should be provided between all of the bars inside a unit frame, negative values move them farther apart, positive values bring them closer together. 0 for no spacing."],
- min = -10, max = 10, step = 0.05, softMin = -5, softMax = 5,
- arg = "bars.spacing",
- hidden = hideAdvancedOption,
- },
- },
- },
- backdrop = {
- order = 2,
- type = "group",
- inline = true,
- name = L["Background/border"],
- args = {
- backgroundColor = {
- order = 1,
- type = "color",
- name = L["Background color"],
- hasAlpha = true,
- set = setColor,
- get = getColor,
- arg = "backdrop.backgroundColor",
- },
- borderColor = {
- order = 2,
- type = "color",
- name = L["Border color"],
- hasAlpha = true,
- set = setColor,
- get = getColor,
- arg = "backdrop.borderColor",
- },
- sep = {
- order = 3,
- type = "description",
- name = "",
- width = "full",
- },
- background = {
- order = 4,
- type = "select",
- name = L["Background"],
- dialogControl = "LSM30_Background",
- values = getMediaData,
- arg = "backdrop.backgroundTexture",
- },
- border = {
- order = 5,
- type = "select",
- name = L["Border"],
- dialogControl = "LSM30_Border",
- values = getMediaData,
- arg = "backdrop.borderTexture",
- },
- inset = {
- order = 5.5,
- type = "range",
- name = L["Inset"],
- desc = L["How far the background should be from the unit frame border."],
- min = -10, max = 10, step = 1,
- hidden = hideAdvancedOption,
- arg = "backdrop.inset",
- },
- sep2 = {
- order = 6,
- type = "description",
- name = "",
- width = "full",
- hidden = hideAdvancedOption,
- },
- edgeSize = {
- order = 7,
- type = "range",
- name = L["Edge size"],
- desc = L["How large the edges should be."],
- hidden = hideAdvancedOption,
- min = 0, max = 20, step = 1,
- arg = "backdrop.edgeSize",
- },
- tileSize = {
- order = 8,
- type = "range",
- name = L["Tile size"],
- desc = L["How large the background should tile"],
- hidden = hideAdvancedOption,
- min = 0, max = 20, step = 1,
- arg = "backdrop.tileSize",
- },
- clip = {
- order = 9,
- type = "range",
- name = L["Clip"],
- desc = L["How close the frame should clip with the border."],
- hidden = hideAdvancedOption,
- min = 0, max = 20, step = 1,
- arg = "backdrop.clip",
- },
- },
- },
- font = {
- order = 3,
- type = "group",
- inline = true,
- name = L["Font"],
- args = {
- color = {
- order = 1,
- type = "color",
- name = L["Default color"],
- desc = L["Default font color, any color tags inside individual tag texts will override this."],
- hasAlpha = true,
- set = setColor,
- get = getColor,
- arg = "font.color",
- hidden = hideAdvancedOption,
- },
- sep = {order = 1.25, type = "description", name = "", hidden = hideAdvancedOption},
- font = {
- order = 1.5,
- type = "select",
- name = L["Font"],
- dialogControl = "LSM30_Font",
- values = getMediaData,
- arg = "font.name",
- },
- size = {
- order = 2,
- type = "range",
- name = L["Size"],
- min = 1, max = 50, step = 1, softMin = 1, softMax = 20,
- arg = "font.size",
- },
- outline = {
- order = 3,
- type = "select",
- name = L["Outline"],
- values = {["OUTLINE"] = L["Thin outline"], ["THICKOUTLINE"] = L["Thick outline"], ["MONOCHROME"] = L["Monochrome"], [""] = L["None"]},
- arg = "font.extra",
- hidden = hideAdvancedOption,
- },
- },
- },
- bar = {
- order = 4,
- type = "group",
- inline = true,
- name = L["Bars"],
- hidden = hideAdvancedOption,
- args = {
- override = {
- order = 0,
- type = "toggle",
- name = L["Override color"],
- desc = L["Forces a static color to be used for the background of all bars"],
- set = function(info, value)
- if( value and not ShadowUF.db.profile.bars.backgroundColor ) then
- ShadowUF.db.profile.bars.backgroundColor = {r = 0, g = 0, b = 0}
- elseif( not value ) then
- ShadowUF.db.profile.bars.backgroundColor = nil
- end
-
- ShadowUF.Layout:Reload()
- end,
- get = function(info)
- return ShadowUF.db.profile.bars.backgroundColor and true or false
- end,
- },
- color = {
- order = 1,
- type = "color",
- name = L["Background color"],
- desc = L["This will override all background colorings for bars including custom set ones."],
- set = setColor,
- get = function(info)
- if( not ShadowUF.db.profile.bars.backgroundColor ) then
- return {r = 0, g = 0, b = 0}
- end
-
- return getColor(info)
- end,
- disabled = function(info) return not ShadowUF.db.profile.bars.backgroundColor end,
- arg = "bars.backgroundColor",
- },
- sep = { order = 2, type = "description", name = "", width = "full"},
- barAlpha = {
- order = 3,
- type = "range",
- name = L["Bar alpha"],
- desc = L["Alpha to use for bar."],
- arg = "bars.alpha",
- min = 0, max = 1, step = 0.05,
- isPercent = true
- },
- backgroundAlpha = {
- order = 4,
- type = "range",
- name = L["Background alpha"],
- desc = L["Alpha to use for bar backgrounds."],
- arg = "bars.backgroundAlpha",
- min = 0, max = 1, step = 0.05,
- isPercent = true
- },
- },
- },
- range = {
- order = 5,
- type = "group",
- inline = true,
- name = L["Range spells"],
- args = {
- friendly = {
- order = 0,
- type = "input",
- name = L["Friendly spell"],
- desc = L["Name of a friendly spell to check range on friendlies.|n|nThis is automatically set for your current class only."],
- validate = validateSpell,
- set = setRange,
- get = getRange,
- },
- hostile = {
- order = 1,
- type = "input",
- name = L["Hostile spell"],
- desc = L["Name of a hostile spell to check range on enemies.|n|nThis is automatically set for your current class only."],
- validate = validateSpell,
- set = setRange,
- get = getRange,
- },
- },
- },
- },
- },
- color = {
- order = 2,
- type = "group",
- name = L["Colors"],
- args = {
- health = {
- order = 1,
- type = "group",
- inline = true,
- name = L["Health"],
- set = setColor,
- get = getColor,
- args = {
- green = {
- order = 1,
- type = "color",
- name = L["High health"],
- desc = L["Health bar color used as the transitional color for 100% -> 50% on players, as well as when your pet is happy."],
- arg = "healthColors.green",
- },
- yellow = {
- order = 2,
- type = "color",
- name = L["Half health"],
- desc = L["Health bar color used as the transitional color for 100% -> 0% on players, as well as when your pet is mildly unhappy."],
- arg = "healthColors.yellow",
- },
- red = {
- order = 3,
- type = "color",
- name = L["Low health"],
- desc = L["Health bar color used as the transitional color for 50% -> 0% on players, as well as when your pet is very unhappy."],
- arg = "healthColors.red",
- },
- friendly = {
- order = 4,
- type = "color",
- name = L["Friendly"],
- desc = L["Health bar color for friendly units."],
- arg = "healthColors.friendly",
- },
- neutral = {
- order = 5,
- type = "color",
- name = L["Neutral"],
- desc = L["Health bar color for neutral units."],
- arg = "healthColors.neutral",
- },
- hostile = {
- order = 6,
- type = "color",
- name = L["Hostile"],
- desc = L["Health bar color for hostile units."],
- arg = "healthColors.hostile",
- },
- static = {
- order = 7,
- type = "color",
- name = L["Static"],
- desc = L["Color to use for health bars that are set to be colored by a static color."],
- arg = "healthColors.static",
- },
- inc = {
- order = 8,
- type = "color",
- name = L["Incoming heal"],
- desc = L["Health bar color to use to show how much healing someone is about to receive."],
- arg = "healthColors.inc",
- },
- enemyUnattack = {
- order = 9,
- type = "color",
- name = L["Unattackable hostile"],
- desc = L["Health bar color to use for hostile units who you cannot attack, used for reaction coloring."],
- hidden = hideAdvancedOption,
- arg = "healthColors.enemyUnattack",
- }
- },
- },
- power = {
- order = 2,
- type = "group",
- inline = true,
- name = L["Power"],
- set = setColor,
- get = getColor,
- args = {
- MANA = {
- order = 0,
- type = "color",
- name = L["Mana"],
- hasAlpha = true,
- width = "half",
- arg = "powerColors.MANA",
- },
- RAGE = {
- order = 1,
- type = "color",
- name = L["Rage"],
- hasAlpha = true,
- width = "half",
- arg = "powerColors.RAGE",
- },
- FOCUS = {
- order = 2,
- type = "color",
- name = L["Focus"],
- hasAlpha = true,
- arg = "powerColors.FOCUS",
- width = "half",
- },
- ENERGY = {
- order = 3,
- type = "color",
- name = L["Energy"],
- hasAlpha = true,
- arg = "powerColors.ENERGY",
- width = "half",
- },
- RUNIC_POWER = {
- order = 6,
- type = "color",
- name = L["Runic Power"],
- hasAlpha = true,
- arg = "powerColors.RUNIC_POWER",
- },
- ECLIPSE_MOON = {
- order = 7,
- type = "color",
- name = L["Eclipse (Moon)"],
- desc = L["Bar coloring for the moon portion of the eclipse bar."],
- hidden = function(info) return select(2, UnitClass("player")) ~= "DRUID" end,
- hasAlpha = true,
- arg = "powerColors.ECLIPSE_MOON",
- },
- ECLIPSE_SUN = {
- order = 8,
- type = "color",
- name = L["Eclipse (Sun)"],
- desc = L["Bar coloring for the moon portion of the eclipse bar."],
- hidden = function(info) return select(2, UnitClass("player")) ~= "DRUID" end,
- hasAlpha = true,
- arg = "powerColors.ECLIPSE_SUN",
- },
- AMMOSLOT = {
- order = 9,
- type = "color",
- name = L["Ammo"],
- hasAlpha = true,
- arg = "powerColors.AMMOSLOT",
- hidden = hideAdvancedOption,
- },
- FUEL = {
- order = 10,
- type = "color",
- name = L["Fuel"],
- hasAlpha = true,
- arg = "powerColors.FUEL",
- hidden = hideAdvancedOption,
- },
- COMBOPOINTS = {
- order = 11,
- type = "color",
- name = L["Combo points"],
- hasAlpha = true,
- arg = "powerColors.COMBOPOINTS",
- },
- HOLYPOWER = {
- order = 12,
- type = "color",
- name = L["Holy Power"],
- hasAlpha = true,
- arg = "powerColors.HOLYPOWER",
- hidden = function(info) return select(2, UnitClass("player")) ~= "PALADIN" end,
- },
- SOULSHARDS = {
- order = 13,
- type = "color",
- name = L["Soul Shards"],
- hasAlpha = true,
- arg = "powerColors.SOULSHARDS",
- hidden = function(info) return select(2, UnitClass("player")) ~= "WARLOCK" end,
- },
- },
- },
- cast = {
- order = 3,
- type = "group",
- inline = true,
- name = L["Cast"],
- set = setColor,
- get = getColor,
- args = {
- cast = {
- order = 0,
- type = "color",
- name = L["Casting"],
- desc = L["Color used when an unit is casting a spell."],
- arg = "castColors.cast",
- },
- channel = {
- order = 1,
- type = "color",
- name = L["Channelling"],
- desc = L["Color used when a cast is a channel."],
- arg = "castColors.channel",
- },
- sep = {
- order = 2,
- type = "description",
- name = "",
- hidden = hideAdvancedOption,
- width = "full",
- },
- finished = {
- order = 3,
- type = "color",
- name = L["Finished cast"],
- desc = L["Color used when a cast is successfully finished."],
- hidden = hideAdvancedOption,
- arg = "castColors.finished",
- },
- interrupted = {
- order = 4,
- type = "color",
- name = L["Cast interrupted"],
- desc = L["Color used when a cast is interrupted either by the caster themselves or by another unit."],
- hidden = hideAdvancedOption,
- arg = "castColors.interrupted",
- },
- uninterruptible = {
- order = 5,
- type = "color",
- name = L["Cast uninterruptible"],
- desc = L["Color used when a cast cannot be interrupted, this is only used for PvE mobs."],
- arg = "castColors.uninterruptible",
- },
- },
- },
- auras = {
- order = 3.5,
- type = "group",
- inline = true,
- name = L["Aura borders"],
- set = setColor,
- get = getColor,
- hidden = hideAdvancedOption,
- args = {
- removableColor = {
- order = 0,
- type = "color",
- name = L["Stealable or Removable"],
- desc = L["Border coloring of stealable or removable auras."],
- arg = "auraColors.removable",
- }
- }
- },
- classColors = {
- order = 4,
- type = "group",
- inline = true,
- name = L["Classes"],
- set = setColor,
- get = getColor,
- args = {}
- },
- },
- },
- profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(ShadowUF.db, true),
- text = {
- type = "group",
- order = 6,
- name = L["Text management"],
- hidden = false,
- args = {
- help = {
- order = 0,
- type = "group",
- inline = true,
- name = L["Help"],
- args = {
- help = {
- order = 0,
- type = "description",
- name = L["You can add additional text with tags enabled using this configuration, note that any additional text added (or removed) effects all units, removing text will reset their settings as well.|n|nKeep in mind, you cannot delete the default text included with the units."],
- },
- },
- },
- add = {
- order = 1,
- name = L["Add new text"],
- inline = true,
- type = "group",
- set = function(info, value) textData[info[#(info)] ] = value end,
- get = function(info, value) return textData[info[#(info)] ] end,
- args = {
- name = {
- order = 0,
- type = "input",
- name = L["Text name"],
- desc = L["Text name that you can use to identify this text from others when configuring."],
- },
- parent = {
- order = 1,
- type = "select",
- name = L["Text parent"],
- desc = L["Where inside the frame the text should be anchored to."],
- values = barModules,
- },
- add = {
- order = 2,
- type = "execute",
- name = L["Add"],
- disabled = function() return not textData.name or textData.name == "" or not textData.parent end,
- func = function(info)
- -- Verify we entered a good name
- textData.name = string.trim(textData.name)
- textData.name = textData.name ~= "" and textData.name or nil
-
- -- Add the new entry
- for _, unit in pairs(ShadowUF.unitList) do
- table.insert(ShadowUF.db.profile.units[unit].text, {enabled = true, name = textData.name or "??", text = "", anchorTo = textData.parent, x = 0, y = 0, anchorPoint = "C", size = 0, width = 0.50})
- end
-
- -- Add it to the GUI
- local id = tostring(#(ShadowUF.db.profile.units.player.text))
- addTextParent.args[id .. ":label"] = addTextLabel
- addTextParent.args[id] = addText
- addTextParent.args[id .. ":sep"] = addTextSep
- options.args.general.args.text.args[textData.parent] = options.args.general.args.text.args[textData.parent] or addTextParent
-
- local parent = string.sub(textData.parent, 2)
- Config.tagWizard[parent] = Config.tagWizard[parent] or Config.parentTable
- Config.tagWizard[parent].args[id] = Config.tagTextTable
- Config.tagWizard[parent].args[id .. ":adv"] = Config.advanceTextTable
-
- quickIDMap[id .. ":adv"] = #(ShadowUF.db.profile.units.player.text)
-
- -- Reset
- textData.name = nil
- textData.parent = nil
-
- end,
- },
- },
- },
- },
- },
- layout = layoutManager,
- },
- }
-
- -- Load text
- for id, text in pairs(ShadowUF.db.profile.units.player.text) do
- addTextParent.args[id .. ":label"] = addTextLabel
- addTextParent.args[tostring(id)] = addText
- addTextParent.args[id .. ":sep"] = addTextSep
- options.args.general.args.text.args[text.anchorTo] = addTextParent
- end
-
-
- Config.classTable = {
- order = 0,
- type = "color",
- name = getName,
- hasAlpha = true,
- width = "half",
- arg = "classColors.$key",
- }
-
- for classToken in pairs(RAID_CLASS_COLORS) do
- options.args.general.args.color.args.classColors.args[classToken] = Config.classTable
- end
-
- options.args.general.args.color.args.classColors.args.PET = Config.classTable
- options.args.general.args.color.args.classColors.args.VEHICLE = Config.classTable
-
- options.args.general.args.profile.order = 4
- end
-
- ---------------------
- -- HIDE BLIZZARD FRAMES CONFIGURATION
- ---------------------
- local function loadHideOptions()
- Config.hideTable = {
- order = function(info) return info[#(info)] == "buffs" and 1 or 2 end,
- type = "toggle",
- name = function(info)
- local key = info[#(info)]
- return L.units[key] and string.format(L["Hide %s frames"], string.lower(L.units[key])) or string.format(L["Hide %s"], key == "cast" and L["player cast bar"] or key == "runes" and L["rune bar"] or key == "buffs" and L["buff frames"] or key == "playerAltPower" and L["player alt. power"])
- end,
- set = function(info, value)
- set(info, value)
- if( value ) then ShadowUF:HideBlizzardFrames() end
- end,
- hidden = false,
- get = get,
- arg = "hidden.$key",
- }
-
- options.args.hideBlizzard = {
- type = "group",
- name = L["Hide Blizzard"],
- desc = getPageDescription,
- args = {
- help = {
- order = 0,
- type = "group",
- name = L["Help"],
- inline = true,
- args = {
- description = {
- type = "description",
- name = L["You will need to do a /console reloadui before a hidden frame becomes visible again.|nPlayer and other unit frames are automatically hidden depending on if you enable the unit in Shadowed Unit Frames."],
- width = "full",
- },
- },
- },
- hide = {
- order = 1,
- type = "group",
- name = L["Frames"],
- inline = true,
- args = {
- buffs = Config.hideTable,
- cast = Config.hideTable,
- runes = Config.hideTable,
- party = Config.hideTable,
- raid = Config.hideTable,
- player = Config.hideTable,
- pet = Config.hideTable,
- target = Config.hideTable,
- focus = Config.hideTable,
- boss = Config.hideTable,
- arena = Config.hideTable,
- playerAltPower = Config.hideTable,
- },
- },
- }
- }
- end
-
- ---------------------
- -- UNIT CONFIGURATION
- ---------------------
- local function loadUnitOptions()
- -- This makes sure we don't end up with any messed up positioning due to two different anchors being used
- local function fixPositions(info)
- local unit = info[2]
- local key = info[#(info)]
-
- if( key == "point" or key == "relativePoint" ) then
- ShadowUF.db.profile.positions[unit].anchorPoint = ""
- ShadowUF.db.profile.positions[unit].movedAnchor = nil
- elseif( key == "anchorPoint" ) then
- ShadowUF.db.profile.positions[unit].point = ""
- ShadowUF.db.profile.positions[unit].relativePoint = ""
- end
-
- -- Reset offset if it was a manually positioned frame, and it got anchored
- -- Why 100/-100 you ask? Because anything else requires some sort of logic applied to it
- -- and this means the frames won't directly overlap too which is a nice bonus
- if( key == "anchorTo" ) then
- ShadowUF.db.profile.positions[unit].x = 100
- ShadowUF.db.profile.positions[unit].y = -100
- end
- end
-
- -- Hide raid option in party config
- local function hideRaidOrAdvancedOption(info)
- if( info[2] == "party" and ShadowUF.db.profile.advanced ) then return false end
-
- return info[2] ~= "raid" and info[2] ~= "raidpet" and info[2] ~= "maintank" and info[2] ~= "mainassist"
- end
-
- local function hideRaidOption(info)
- return info[2] ~= "raid" and info[2] ~= "raidpet" and info[2] ~= "maintank" and info[2] ~= "mainassist"
- end
-
- local function hideSplitOrRaidOption(info)
- if( info[2] == "raid" and ShadowUF.db.profile.units.raid.frameSplit ) then
- return true
- end
-
- return hideRaidOption(info)
- end
-
- -- Not every option should be changed via global settings
- local function hideSpecialOptions(info)
- local unit = info[2]
- if( unit == "global" or unit == "partypet" ) then
- return true
- end
-
- return hideAdvancedOption(info)
- end
-
- local function checkNumber(info, value)
- return tonumber(value)
- end
-
- local function setPosition(info, value)
- ShadowUF.db.profile.positions[info[2]][info[#(info)]] = value
- fixPositions(info)
-
- if( info[2] == "raid" or info[2] == "raidpet" or info[2] == "maintank" or info[2] == "mainassist" or info[2] == "party" or info[2] == "boss" or info[2] == "arena" ) then
- ShadowUF.Units:ReloadHeader(info[2])
- else
- ShadowUF.Layout:Reload(info[2])
- end
- end
-
- l…
Large files files are truncated, but you can click here to view the full file