PageRenderTime 62ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 2ms

/ShadowedUF_Options/config.lua

https://bitbucket.org/Ahmil/wowmodmodsoriginals
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

  1. local Config = {}
  2. local AceDialog, AceRegistry, AceGUI, SML, registered, options
  3. local playerClass = select(2, UnitClass("player"))
  4. local modifyUnits, globalConfig = {}, {}
  5. local L = ShadowUF.L
  6. ShadowUF.Config = Config
  7. --[[
  8. The part that makes configuration a pain when you actually try is it gets unwieldly when you're adding special code to deal with
  9. showing help for certain cases, swapping tabs etc that makes it work smoothly.
  10. 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
  11. I want to get done with first.
  12. ]]
  13. local unitCategories = {
  14. player = {"player", "pet"},
  15. general = {"target", "targettarget", "targettargettarget", "focus", "focustarget", "pettarget"},
  16. party = {"party", "partypet", "partytarget"},
  17. raid = {"raid", "raidpet", "boss", "bosstarget", "maintank", "maintanktarget", "mainassist", "mainassisttarget"},
  18. arena = {"arena", "arenapet", "arenatarget"}}
  19. local UNIT_DESC = {
  20. ["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."],
  21. ["mainassist"] = L["Main Assists's are set by the Blizzard Main Assist system or mods that use them such as oRA3."],
  22. ["maintank"] = L["Main Tank's are set by the Blizzard Main Tank system or mods that use them such as oRA3."],
  23. }
  24. local PAGE_DESC = {
  25. ["general"] = L["General configuration to all enabled units."],
  26. ["enableUnits"] = L["Various units can be enabled through this page, such as raid or party targets."],
  27. ["hideBlizzard"] = L["Hiding and showing various aspects of the default UI such as the player buff frames."],
  28. ["units"] = L["Configuration to specific unit frames."],
  29. ["visibility"] = L["Disabling unit modules in various instances."],
  30. ["tags"] = L["Advanced tag management, allows you to add your own custom tags."],
  31. ["filter"] = L["Simple aura filtering by whitelists and blacklists."],
  32. }
  33. 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"]}
  34. local AREA_NAMES = {["arena"] = L["Arenas"],["none"] = L["Everywhere else"], ["party"] = L["Party instances"], ["pvp"] = L["Battlegrounds"], ["raid"] = L["Raid instances"]}
  35. local INDICATOR_DESC = {
  36. ["leader"] = L["Crown indicator for group leaders."], ["lfdRole"] = L["Role the unit is playing in dungeons formed through the Looking For Dungeon system."],
  37. ["masterLoot"] = L["Bag indicator for master looters."], ["pvp"] = L["PVP flag indicator, Horde for Horde flagged pvpers and Alliance for Alliance flagged pvpers."],
  38. ["raidTarget"] = L["Raid target indicator."], ["ready"] = L["Ready status of group members."],
  39. ["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."]}
  40. 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"]}
  41. 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"]}
  42. 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"]}
  43. local unitOrder = {}
  44. for order, unit in pairs(ShadowUF.unitList) do unitOrder[unit] = order end
  45. local fullReload = {["bars"] = true, ["auras"] = true, ["backdrop"] = true, ["font"] = true, ["classColors"] = true, ["powerColors"] = true, ["healthColors"] = true, ["xpColors"] = true, ["omnicc"] = true}
  46. local quickIDMap = {}
  47. -- Helper functions
  48. local function getPageDescription(info)
  49. return PAGE_DESC[info[#(info)]]
  50. end
  51. local function getFrameName(unit)
  52. if( unit == "raidpet" or unit == "raid" or unit == "party" or unit == "maintank" or unit == "mainassist" or unit == "boss" or unit == "arena" ) then
  53. return string.format("#SUFHeader%s", unit)
  54. end
  55. return string.format("#SUFUnit%s", unit)
  56. end
  57. local anchorList = {}
  58. local function getAnchorParents(info)
  59. local unit = info[2]
  60. for k in pairs(anchorList) do anchorList[k] = nil end
  61. if( ShadowUF.Units.childUnits[unit] ) then
  62. anchorList["$parent"] = string.format(L["%s member"], L.units[ShadowUF.Units.childUnits[unit]])
  63. return anchorList
  64. end
  65. anchorList["UIParent"] = L["Screen"]
  66. -- Don't let a frame anchor to a frame thats anchored to it already (Stop infinite loops-o-doom)
  67. local currentName = getFrameName(unit)
  68. for _, unitID in pairs(ShadowUF.unitList) do
  69. if( unitID ~= unit and ShadowUF.db.profile.positions[unitID] and ShadowUF.db.profile.positions[unitID].anchorTo ~= currentName ) then
  70. anchorList[getFrameName(unitID)] = string.format(L["%s frames"], L.units[unitID] or unitID)
  71. end
  72. end
  73. return anchorList
  74. end
  75. local function selectDialogGroup(group, key)
  76. AceDialog.Status.ShadowedUF.children[group].status.groups.selected = key
  77. AceRegistry:NotifyChange("ShadowedUF")
  78. end
  79. local function selectTabGroup(group, subGroup, key)
  80. AceDialog.Status.ShadowedUF.children[group].status.groups.selected = subGroup
  81. AceDialog.Status.ShadowedUF.children[group].children[subGroup].status.groups.selected = key
  82. AceRegistry:NotifyChange("ShadowedUF")
  83. end
  84. local function hideAdvancedOption(info)
  85. return not ShadowUF.db.profile.advanced
  86. end
  87. local function hideBasicOption(info)
  88. return ShadowUF.db.profile.advanced
  89. end
  90. local function isUnitDisabled(info)
  91. local unit = info[#(info)]
  92. local enabled = ShadowUF.db.profile.units[unit].enabled
  93. for _, visibility in pairs(ShadowUF.db.profile.visibility) do
  94. if( visibility[unit] ) then
  95. enabled = visibility[unit]
  96. break
  97. end
  98. end
  99. return not enabled
  100. end
  101. local function mergeTables(parent, child)
  102. for key, value in pairs(child) do
  103. if( type(parent[key]) == "table" ) then
  104. parent[key] = mergeTables(parent[key], value)
  105. elseif( type(value) == "table" ) then
  106. parent[key] = CopyTable(value)
  107. elseif( parent[key] == nil ) then
  108. parent[key] = value
  109. end
  110. end
  111. return parent
  112. end
  113. local function getName(info)
  114. local key = info[#(info)]
  115. if( ShadowUF.modules[key] and ShadowUF.modules[key].moduleName ) then
  116. return ShadowUF.modules[key].moduleName
  117. end
  118. return LOCALIZED_CLASS_NAMES_MALE[key] or INDICATOR_NAMES[key] or L.units[key] or TAG_GROUPS[key] or L[key]
  119. end
  120. local function getUnitOrder(info)
  121. return unitOrder[info[#(info)]]
  122. end
  123. local function isModifiersSet(info)
  124. if( info[2] ~= "global" ) then return false end
  125. for k in pairs(modifyUnits) do return false end
  126. return true
  127. end
  128. -- These are for setting simple options like bars.texture = "Default" or locked = true
  129. local function set(info, value)
  130. local cat, key = string.split(".", info.arg)
  131. if( key == "$key" ) then key = info[#(info)] end
  132. if( not key ) then
  133. ShadowUF.db.profile[cat] = value
  134. else
  135. ShadowUF.db.profile[cat][key] = value
  136. end
  137. if( cat and fullReload[cat] ) then
  138. ShadowUF.Layout:CheckMedia()
  139. ShadowUF.Layout:Reload()
  140. end
  141. end
  142. local function get(info)
  143. local cat, key = string.split(".", info.arg)
  144. if( key == "$key" ) then key = info[#(info)] end
  145. if( not key ) then
  146. return ShadowUF.db.profile[cat]
  147. else
  148. return ShadowUF.db.profile[cat][key]
  149. end
  150. end
  151. local function setColor(info, r, g, b, a)
  152. local color = get(info)
  153. color.r, color.g, color.b, color.a = r, g, b, a
  154. set(info, color)
  155. end
  156. local function getColor(info)
  157. local color = get(info)
  158. return color.r, color.g, color.b, color.a
  159. end
  160. -- These are for setting complex options like units.player.auras.buffs.enabled = true or units.player.portrait.enabled = true
  161. local function setVariable(unit, moduleKey, moduleSubKey, key, value)
  162. local configTable = unit == "global" and globalConfig or ShadowUF.db.profile.units[unit]
  163. -- For setting options like units.player.auras.buffs.enabled = true
  164. if( moduleKey and moduleSubKey and configTable[moduleKey][moduleSubKey] ) then
  165. configTable[moduleKey][moduleSubKey][key] = value
  166. ShadowUF.Layout:Reload(unit)
  167. -- For setting options like units.player.portrait.enabled = true
  168. elseif( moduleKey and not moduleSubKey and configTable[moduleKey] ) then
  169. configTable[moduleKey][key] = value
  170. ShadowUF.Layout:Reload(unit)
  171. -- For setting options like units.player.height = 50
  172. elseif( not moduleKey and not moduleSubKey ) then
  173. configTable[key] = value
  174. ShadowUF.Layout:Reload(unit)
  175. end
  176. end
  177. local function specialRestricted(unit, moduleKey, moduleSubKey, key)
  178. if( ShadowUF.fakeUnits[unit] and ( key == "colorAggro" or key == "aggro" or moduleKey == "incHeal" or moduleKey == "castBar" ) ) then
  179. return true
  180. elseif( moduleKey == "healthBar" and unit == "player" and key == "reaction" ) then
  181. return true
  182. end
  183. end
  184. local function setDirectUnit(unit, moduleKey, moduleSubKey, key, value)
  185. if( unit == "global" ) then
  186. for unit in pairs(modifyUnits) do
  187. if( not specialRestricted(unit, moduleKey, moduleSubKey, key) ) then
  188. setVariable(unit, moduleKey, moduleSubKey, key, value)
  189. end
  190. end
  191. setVariable("global", moduleKey, moduleSubKey, key, value)
  192. else
  193. setVariable(unit, moduleKey, moduleSubKey, key, value)
  194. end
  195. end
  196. local function setUnit(info, value)
  197. local unit = info[2]
  198. -- auras, buffs, enabled / text, 1, text / portrait, enabled
  199. local moduleKey, moduleSubKey, key = string.split(".", info.arg)
  200. if( not moduleSubKey ) then key = moduleKey moduleKey = nil end
  201. if( moduleSubKey and not key ) then key = moduleSubKey moduleSubKey = nil end
  202. if( moduleSubKey == "$parent" ) then moduleSubKey = info[#(info) - 1] end
  203. if( moduleKey == "$parent" ) then moduleKey = info[#(info) - 1] end
  204. if( tonumber(moduleSubKey) ) then moduleSubKey = tonumber(moduleSubKey) end
  205. setDirectUnit(unit, moduleKey, moduleSubKey, key, value)
  206. end
  207. local function getVariable(unit, moduleKey, moduleSubKey, key)
  208. local configTbl = unit == "global" and globalConfig or ShadowUF.db.profile.units[unit]
  209. if( moduleKey and moduleSubKey ) then
  210. return configTbl[moduleKey][moduleSubKey] and configTbl[moduleKey][moduleSubKey][key]
  211. elseif( moduleKey and not moduleSubKey ) then
  212. return configTbl[moduleKey] and configTbl[moduleKey][key]
  213. end
  214. return configTbl[key]
  215. end
  216. local function getUnit(info)
  217. local moduleKey, moduleSubKey, key = string.split(".", info.arg)
  218. if( not moduleSubKey ) then key = moduleKey moduleKey = nil end
  219. if( moduleSubKey and not key ) then key = moduleSubKey moduleSubKey = nil end
  220. if( moduleSubKey == "$parent" ) then moduleSubKey = info[#(info) - 1] end
  221. if( moduleKey == "$parent" ) then moduleKey = info[#(info) - 1] end
  222. if( tonumber(moduleSubKey) ) then moduleSubKey = tonumber(moduleSubKey) end
  223. return getVariable(info[2], moduleKey, moduleSubKey, key)
  224. end
  225. -- Tag functions
  226. local function getTagName(info)
  227. local tag = info[#(info)]
  228. if( ShadowUF.db.profile.tags[tag] and ShadowUF.db.profile.tags[tag].name ) then
  229. return ShadowUF.db.profile.tags[tag].name
  230. end
  231. return ShadowUF.Tags.defaultNames[tag] or tag
  232. end
  233. local function getTagHelp(info)
  234. local tag = info[#(info)]
  235. return ShadowUF.Tags.defaultHelp[tag] or ShadowUF.db.profile.tags[tag] and ShadowUF.db.profile.tags[tag].help
  236. end
  237. -- Module functions
  238. local function hideRestrictedOption(info)
  239. local unit = type(info.arg) == "number" and info[#(info) - info.arg] or info[2]
  240. local key = info[#(info)]
  241. if( ShadowUF.modules[key] and ShadowUF.modules[key].moduleClass and ShadowUF.modules[key].moduleClass ~= playerClass ) then
  242. return true
  243. elseif( key == "incHeal" and not ShadowUF.modules.incHeal ) then
  244. return true
  245. -- Non-standard units do not support color by aggro or incoming heal
  246. elseif( key == "colorAggro" or key == "incHeal" or key == "aggro" ) then
  247. return string.match(unit, "%w+target" )
  248. -- Fall back for indicators, no variable table so it shouldn't be shown
  249. elseif( info[#(info) - 1] == "indicators" ) then
  250. if( ( unit == "global" and not globalConfig.indicators[key] ) or ( unit ~= "global" and not ShadowUF.db.profile.units[unit].indicators[key] ) ) then
  251. return true
  252. end
  253. -- Fall back, no variable table so it shouldn't be shown
  254. elseif( ( unit == "global" and not globalConfig[key] ) or ( unit ~= "global" and not ShadowUF.db.profile.units[unit][key] ) ) then
  255. return true
  256. end
  257. return false
  258. end
  259. local function getModuleOrder(info)
  260. local key = info[#(info)]
  261. return key == "healthBar" and 1 or key == "powerBar" and 2 or key == "castBar" and 3 or 4
  262. end
  263. -- Expose these for modules
  264. Config.getAnchorParents = getAnchorParents
  265. Config.hideAdvancedOption = hideAdvancedOption
  266. Config.isUnitDisabled = isUnitDisabled
  267. Config.selectDialogGroup = selectDialogGroup
  268. Config.selectTabGroup = selectTabGroup
  269. Config.getName = getName
  270. Config.getUnitOrder = getUnitOrder
  271. Config.isModifiersSet = isModifiersSet
  272. Config.set = set
  273. Config.get = get
  274. Config.setUnit = setUnit
  275. Config.setVariable = setVariable
  276. Config.getUnit = getUnit
  277. Config.getVariable = getVariable
  278. Config.hideRestrictedOption = hideRestrictedOption
  279. Config.hideBasicOption = hideBasicOption
  280. --------------------
  281. -- GENERAL CONFIGURATION
  282. ---------------------
  283. local function loadGeneralOptions()
  284. SML = SML or LibStub:GetLibrary("LibSharedMedia-3.0")
  285. local MediaList = {}
  286. local function getMediaData(info)
  287. local mediaType = info[#(info)]
  288. MediaList[mediaType] = MediaList[mediaType] or {}
  289. for k in pairs(MediaList[mediaType]) do MediaList[mediaType][k] = nil end
  290. for _, name in pairs(SML:List(mediaType)) do
  291. MediaList[mediaType][name] = name
  292. end
  293. return MediaList[mediaType]
  294. end
  295. local barModules = {}
  296. for key, module in pairs(ShadowUF.modules) do
  297. if( module.moduleHasBar ) then
  298. barModules["$" .. key] = module.moduleName
  299. end
  300. end
  301. local addTextParent = {
  302. order = 4,
  303. type = "group",
  304. inline = true,
  305. name = function(info) return barModules[info[#(info)]] or string.sub(info[#(info)], 2) end,
  306. hidden = function(info)
  307. for _, text in pairs(ShadowUF.db.profile.units.player.text) do
  308. if( text.anchorTo == info[#(info)] ) then
  309. return false
  310. end
  311. end
  312. return true
  313. end,
  314. args = {},
  315. }
  316. local addTextLabel = {
  317. order = function(info) return tonumber(string.match(info[#(info)], "(%d+)")) end,
  318. type = "description",
  319. width = "",
  320. fontSize = "medium",
  321. hidden = function(info)
  322. local id = tonumber(string.match(info[#(info)], "(%d+)"))
  323. if( not getVariable("player", "text", nil, id) ) then return true end
  324. return getVariable("player", "text", id, "anchorTo") ~= info[#(info) - 1]
  325. end,
  326. name = function(info)
  327. return getVariable("player", "text", tonumber(string.match(info[#(info)], "(%d+)")), "name")
  328. end,
  329. }
  330. local addTextSep = {
  331. order = function(info) return tonumber(string.match(info[#(info)], "(%d+)")) + 0.75 end,
  332. type = "description",
  333. width = "full",
  334. hidden = function(info)
  335. local id = tonumber(string.match(info[#(info)], "(%d+)"))
  336. if( not getVariable("player", "text", nil, id) ) then return true end
  337. return getVariable("player", "text", id, "anchorTo") ~= info[#(info) - 1]
  338. end,
  339. name = "",
  340. }
  341. local addText = {
  342. order = function(info) return info[#(info)] + 0.5 end,
  343. type = "execute",
  344. width = "half",
  345. name = L["Delete"],
  346. hidden = function(info)
  347. local id = tonumber(info[#(info)])
  348. if( not getVariable("player", "text", nil, id) ) then return true end
  349. return getVariable("player", "text", id, "anchorTo") ~= info[#(info) - 1]
  350. end,
  351. disabled = function(info) return tonumber(info[#(info)]) <= 5 end,
  352. confirmText = L["Are you sure you want to delete this text? All settings for it will be deleted."],
  353. confirm = true,
  354. func = function(info)
  355. local id = tonumber(info[#(info)])
  356. for _, unit in pairs(ShadowUF.unitList) do
  357. table.remove(ShadowUF.db.profile.units[unit].text, id)
  358. end
  359. addTextParent.args[info[#(info)]] = nil
  360. ShadowUF.Layout:Reload()
  361. end,
  362. }
  363. local function validateSpell(info, spell)
  364. if( spell and spell ~= "" and not GetSpellInfo(spell) ) then
  365. return string.format(L["Invalid spell \"%s\" entered."], spell or "")
  366. end
  367. return true
  368. end
  369. local function setRange(info, spell)
  370. ShadowUF.db.profile.range[info[#(info)] .. playerClass] = spell and spell ~= "" and spell or nil
  371. ShadowUF.Layout:Reload()
  372. end
  373. local function getRange(info, spell)
  374. local spell = ShadowUF.db.profile.range[info[#(info)] .. playerClass]
  375. return spell and spell ~= "" and spell or ShadowUF.modules.range[info[#(info)]][playerClass]
  376. end
  377. local textData = {}
  378. local function writeTable(tbl)
  379. local data = ""
  380. for key, value in pairs(tbl) do
  381. local valueType = type(value)
  382. -- Wrap the key in brackets if it's a number
  383. if( type(key) == "number" ) then
  384. key = string.format("[%s]", key)
  385. -- Wrap the string with quotes if it has a space in it
  386. elseif( string.match(key, "[%p%s%c]") ) then
  387. key = string.format("['%s']", string.gsub(key, "'", "\\'"))
  388. end
  389. -- foo = {bar = 5}
  390. if( valueType == "table" ) then
  391. data = string.format("%s%s=%s;", data, key, writeTable(value))
  392. -- foo = true / foo = 5
  393. elseif( valueType == "number" or valueType == "boolean" ) then
  394. data = string.format("%s%s=%s;", data, key, tostring(value))
  395. -- foo = "bar"
  396. else
  397. data = string.format("%s%s='%s';", data, key, string.gsub(tostring(value), "'", "\\'"))
  398. end
  399. end
  400. return "{" .. data .. "}"
  401. end
  402. local layoutData = {positions = true, visibility = true, modules = false}
  403. local layoutManager = {
  404. type = "group",
  405. order = 7,
  406. name = L["Layout manager"],
  407. childGroups = "tab",
  408. hidden = hideAdvancedOption,
  409. args = {
  410. import = {
  411. order = 1,
  412. type = "group",
  413. name = L["Import"],
  414. hidden = false,
  415. args = {
  416. help = {
  417. order = 1,
  418. type = "group",
  419. inline = true,
  420. name = function(info) return layoutData.error and L["Error"] or L["Help"] end,
  421. args = {
  422. help = {
  423. order = 1,
  424. type = "description",
  425. name = function(info)
  426. if( ShadowUF.db:GetCurrentProfile() == "Import Backup" ) then
  427. 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."]
  428. end
  429. 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."]
  430. end
  431. },
  432. },
  433. },
  434. positions = {
  435. order = 2,
  436. type = "toggle",
  437. name = L["Import unit frame positions"],
  438. set = function(info, value) layoutData[info[#(info)]] = value end,
  439. get = function(info) return layoutData[info[#(info)]] end,
  440. width = "double",
  441. },
  442. visibility = {
  443. order = 3,
  444. type = "toggle",
  445. name = L["Import visibility settings"],
  446. set = function(info, value) layoutData[info[#(info)]] = value end,
  447. get = function(info) return layoutData[info[#(info)]] end,
  448. width = "double",
  449. },
  450. modules = {
  451. order = 4,
  452. type = "toggle",
  453. name = L["Import non-standard module settings"],
  454. desc = L["Will not import settings of modules that are not included with Shadowed Unit Frames by default."],
  455. set = function(info, value) layoutData[info[#(info)]] = value end,
  456. get = function(info) return layoutData[info[#(info)]] end,
  457. width = "double",
  458. },
  459. import = {
  460. order = 5,
  461. type = "input",
  462. name = L["Code"],
  463. multiline = true,
  464. width = "full",
  465. get = false,
  466. disabled = function() return ShadowUF.db:GetCurrentProfile() == "Import Backup" end,
  467. set = function(info, import)
  468. local layout, err = loadstring(string.format([[return %s]], import))
  469. if( err ) then
  470. layoutData.error = string.format(L["Failed to import layout, error:|n|n%s"], err)
  471. return
  472. end
  473. layout = layout()
  474. -- Strip position settings
  475. if( not layoutData.positions ) then
  476. layout.positions = nil
  477. end
  478. -- Strip visibility settings
  479. if( not layoutData.visibility ) then
  480. layout.visibility = nil
  481. end
  482. -- Strip any units we don't have included by default
  483. for unit in pairs(layout.units) do
  484. if( not ShadowUF.defaults.profile.units[unit] ) then
  485. layout.units[unit] = nil
  486. end
  487. end
  488. -- Strip module settings that aren't with SUF by default
  489. if( not layoutData.modules ) then
  490. 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}
  491. for _, unitData in pairs(layout.units) do
  492. for key, data in pairs(unitData) do
  493. if( type(data) == "table" and not validModules[key] and ShadowUF.modules[key] ) then
  494. unitData[key] = nil
  495. end
  496. end
  497. end
  498. end
  499. -- Check if we need move over the visibility and positions info
  500. layout.positions = layout.positions or CopyTable(ShadowUF.db.profile.positions)
  501. layout.visibility = layout.visibility or CopyTable(ShadowUF.db.profile.positions)
  502. -- Now backup the profile
  503. local currentLayout = ShadowUF.db:GetCurrentProfile()
  504. ShadowUF.layoutImporting = true
  505. ShadowUF.db:SetProfile("Import Backup")
  506. ShadowUF.db:CopyProfile(currentLayout)
  507. ShadowUF.db:SetProfile(currentLayout)
  508. ShadowUF.db:ResetProfile()
  509. ShadowUF.layoutImporting = nil
  510. -- Overwrite everything we did import
  511. ShadowUF:LoadDefaultLayout()
  512. for key, data in pairs(layout) do
  513. if( type(data) == "table" ) then
  514. ShadowUF.db.profile[key] = CopyTable(data)
  515. else
  516. ShadowUF.db.profile[key] = data
  517. end
  518. end
  519. ShadowUF:ProfilesChanged()
  520. end,
  521. },
  522. },
  523. },
  524. export = {
  525. order = 2,
  526. type = "group",
  527. name = L["Export"],
  528. hidden = false,
  529. args = {
  530. help = {
  531. order = 1,
  532. type = "group",
  533. inline = true,
  534. name = L["Help"],
  535. args = {
  536. help = {
  537. order = 1,
  538. type = "description",
  539. 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."],
  540. },
  541. },
  542. },
  543. doExport = {
  544. order = 2,
  545. type = "execute",
  546. name = L["Export"],
  547. func = function(info)
  548. layoutData.export = writeTable(ShadowUF.db.profile)
  549. end,
  550. },
  551. export = {
  552. order = 3,
  553. type = "input",
  554. name = L["Code"],
  555. multiline = true,
  556. width = "full",
  557. set = false,
  558. get = function(info) return layoutData[info[#(info)]] end,
  559. },
  560. },
  561. },
  562. },
  563. }
  564. options.args.general = {
  565. type = "group",
  566. childGroups = "tab",
  567. name = L["General"],
  568. args = {
  569. general = {
  570. type = "group",
  571. order = 1,
  572. name = L["General"],
  573. set = set,
  574. get = get,
  575. args = {
  576. general = {
  577. order = 1,
  578. type = "group",
  579. inline = true,
  580. name = L["General"],
  581. args = {
  582. locked = {
  583. order = 1,
  584. type = "toggle",
  585. name = L["Lock frames"],
  586. desc = L["Enables configuration mode, letting you move and giving you example frames to setup."],
  587. set = function(info, value)
  588. set(info, value)
  589. ShadowUF.modules.movers:Update()
  590. end,
  591. arg = "locked",
  592. },
  593. sep = {
  594. order = 1.5,
  595. type = "description",
  596. name = "",
  597. width = "full",
  598. hidden = hideAdvancedOption,
  599. },
  600. advanced = {
  601. order = 2,
  602. type = "toggle",
  603. name = L["Advanced"],
  604. 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."],
  605. arg = "advanced",
  606. },
  607. omnicc = {
  608. order = 2.5,
  609. type = "toggle",
  610. name = L["Disable OmniCC"],
  611. desc = L["Disables showing OmniCC timers in all Shadowed Unit Frame auras."],
  612. arg = "omnicc",
  613. hidden = hideAdvancedOption,
  614. },
  615. hideCombat = {
  616. order = 3,
  617. type = "toggle",
  618. name = L["Hide tooltips in combat"],
  619. desc = L["Prevents unit tooltips from showing while in combat."],
  620. arg = "tooltipCombat",
  621. },
  622. auraBorder = {
  623. order = 5,
  624. type = "select",
  625. name = L["Aura border style"],
  626. desc = L["Style of borders to show for all auras."],
  627. values = {["dark"] = L["Dark"], ["light"] = L["Light"], ["blizzard"] = L["Blizzard"], [""] = L["None"]},
  628. arg = "auras.borderType",
  629. },
  630. statusbar = {
  631. order = 6,
  632. type = "select",
  633. name = L["Bar texture"],
  634. dialogControl = "LSM30_Statusbar",
  635. values = getMediaData,
  636. arg = "bars.texture",
  637. },
  638. spacing = {
  639. order = 7,
  640. type = "range",
  641. name = L["Bar spacing"],
  642. 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."],
  643. min = -10, max = 10, step = 0.05, softMin = -5, softMax = 5,
  644. arg = "bars.spacing",
  645. hidden = hideAdvancedOption,
  646. },
  647. },
  648. },
  649. backdrop = {
  650. order = 2,
  651. type = "group",
  652. inline = true,
  653. name = L["Background/border"],
  654. args = {
  655. backgroundColor = {
  656. order = 1,
  657. type = "color",
  658. name = L["Background color"],
  659. hasAlpha = true,
  660. set = setColor,
  661. get = getColor,
  662. arg = "backdrop.backgroundColor",
  663. },
  664. borderColor = {
  665. order = 2,
  666. type = "color",
  667. name = L["Border color"],
  668. hasAlpha = true,
  669. set = setColor,
  670. get = getColor,
  671. arg = "backdrop.borderColor",
  672. },
  673. sep = {
  674. order = 3,
  675. type = "description",
  676. name = "",
  677. width = "full",
  678. },
  679. background = {
  680. order = 4,
  681. type = "select",
  682. name = L["Background"],
  683. dialogControl = "LSM30_Background",
  684. values = getMediaData,
  685. arg = "backdrop.backgroundTexture",
  686. },
  687. border = {
  688. order = 5,
  689. type = "select",
  690. name = L["Border"],
  691. dialogControl = "LSM30_Border",
  692. values = getMediaData,
  693. arg = "backdrop.borderTexture",
  694. },
  695. inset = {
  696. order = 5.5,
  697. type = "range",
  698. name = L["Inset"],
  699. desc = L["How far the background should be from the unit frame border."],
  700. min = -10, max = 10, step = 1,
  701. hidden = hideAdvancedOption,
  702. arg = "backdrop.inset",
  703. },
  704. sep2 = {
  705. order = 6,
  706. type = "description",
  707. name = "",
  708. width = "full",
  709. hidden = hideAdvancedOption,
  710. },
  711. edgeSize = {
  712. order = 7,
  713. type = "range",
  714. name = L["Edge size"],
  715. desc = L["How large the edges should be."],
  716. hidden = hideAdvancedOption,
  717. min = 0, max = 20, step = 1,
  718. arg = "backdrop.edgeSize",
  719. },
  720. tileSize = {
  721. order = 8,
  722. type = "range",
  723. name = L["Tile size"],
  724. desc = L["How large the background should tile"],
  725. hidden = hideAdvancedOption,
  726. min = 0, max = 20, step = 1,
  727. arg = "backdrop.tileSize",
  728. },
  729. clip = {
  730. order = 9,
  731. type = "range",
  732. name = L["Clip"],
  733. desc = L["How close the frame should clip with the border."],
  734. hidden = hideAdvancedOption,
  735. min = 0, max = 20, step = 1,
  736. arg = "backdrop.clip",
  737. },
  738. },
  739. },
  740. font = {
  741. order = 3,
  742. type = "group",
  743. inline = true,
  744. name = L["Font"],
  745. args = {
  746. color = {
  747. order = 1,
  748. type = "color",
  749. name = L["Default color"],
  750. desc = L["Default font color, any color tags inside individual tag texts will override this."],
  751. hasAlpha = true,
  752. set = setColor,
  753. get = getColor,
  754. arg = "font.color",
  755. hidden = hideAdvancedOption,
  756. },
  757. sep = {order = 1.25, type = "description", name = "", hidden = hideAdvancedOption},
  758. font = {
  759. order = 1.5,
  760. type = "select",
  761. name = L["Font"],
  762. dialogControl = "LSM30_Font",
  763. values = getMediaData,
  764. arg = "font.name",
  765. },
  766. size = {
  767. order = 2,
  768. type = "range",
  769. name = L["Size"],
  770. min = 1, max = 50, step = 1, softMin = 1, softMax = 20,
  771. arg = "font.size",
  772. },
  773. outline = {
  774. order = 3,
  775. type = "select",
  776. name = L["Outline"],
  777. values = {["OUTLINE"] = L["Thin outline"], ["THICKOUTLINE"] = L["Thick outline"], ["MONOCHROME"] = L["Monochrome"], [""] = L["None"]},
  778. arg = "font.extra",
  779. hidden = hideAdvancedOption,
  780. },
  781. },
  782. },
  783. bar = {
  784. order = 4,
  785. type = "group",
  786. inline = true,
  787. name = L["Bars"],
  788. hidden = hideAdvancedOption,
  789. args = {
  790. override = {
  791. order = 0,
  792. type = "toggle",
  793. name = L["Override color"],
  794. desc = L["Forces a static color to be used for the background of all bars"],
  795. set = function(info, value)
  796. if( value and not ShadowUF.db.profile.bars.backgroundColor ) then
  797. ShadowUF.db.profile.bars.backgroundColor = {r = 0, g = 0, b = 0}
  798. elseif( not value ) then
  799. ShadowUF.db.profile.bars.backgroundColor = nil
  800. end
  801. ShadowUF.Layout:Reload()
  802. end,
  803. get = function(info)
  804. return ShadowUF.db.profile.bars.backgroundColor and true or false
  805. end,
  806. },
  807. color = {
  808. order = 1,
  809. type = "color",
  810. name = L["Background color"],
  811. desc = L["This will override all background colorings for bars including custom set ones."],
  812. set = setColor,
  813. get = function(info)
  814. if( not ShadowUF.db.profile.bars.backgroundColor ) then
  815. return {r = 0, g = 0, b = 0}
  816. end
  817. return getColor(info)
  818. end,
  819. disabled = function(info) return not ShadowUF.db.profile.bars.backgroundColor end,
  820. arg = "bars.backgroundColor",
  821. },
  822. sep = { order = 2, type = "description", name = "", width = "full"},
  823. barAlpha = {
  824. order = 3,
  825. type = "range",
  826. name = L["Bar alpha"],
  827. desc = L["Alpha to use for bar."],
  828. arg = "bars.alpha",
  829. min = 0, max = 1, step = 0.05,
  830. isPercent = true
  831. },
  832. backgroundAlpha = {
  833. order = 4,
  834. type = "range",
  835. name = L["Background alpha"],
  836. desc = L["Alpha to use for bar backgrounds."],
  837. arg = "bars.backgroundAlpha",
  838. min = 0, max = 1, step = 0.05,
  839. isPercent = true
  840. },
  841. },
  842. },
  843. range = {
  844. order = 5,
  845. type = "group",
  846. inline = true,
  847. name = L["Range spells"],
  848. args = {
  849. friendly = {
  850. order = 0,
  851. type = "input",
  852. name = L["Friendly spell"],
  853. desc = L["Name of a friendly spell to check range on friendlies.|n|nThis is automatically set for your current class only."],
  854. validate = validateSpell,
  855. set = setRange,
  856. get = getRange,
  857. },
  858. hostile = {
  859. order = 1,
  860. type = "input",
  861. name = L["Hostile spell"],
  862. desc = L["Name of a hostile spell to check range on enemies.|n|nThis is automatically set for your current class only."],
  863. validate = validateSpell,
  864. set = setRange,
  865. get = getRange,
  866. },
  867. },
  868. },
  869. },
  870. },
  871. color = {
  872. order = 2,
  873. type = "group",
  874. name = L["Colors"],
  875. args = {
  876. health = {
  877. order = 1,
  878. type = "group",
  879. inline = true,
  880. name = L["Health"],
  881. set = setColor,
  882. get = getColor,
  883. args = {
  884. green = {
  885. order = 1,
  886. type = "color",
  887. name = L["High health"],
  888. desc = L["Health bar color used as the transitional color for 100% -> 50% on players, as well as when your pet is happy."],
  889. arg = "healthColors.green",
  890. },
  891. yellow = {
  892. order = 2,
  893. type = "color",
  894. name = L["Half health"],
  895. desc = L["Health bar color used as the transitional color for 100% -> 0% on players, as well as when your pet is mildly unhappy."],
  896. arg = "healthColors.yellow",
  897. },
  898. red = {
  899. order = 3,
  900. type = "color",
  901. name = L["Low health"],
  902. desc = L["Health bar color used as the transitional color for 50% -> 0% on players, as well as when your pet is very unhappy."],
  903. arg = "healthColors.red",
  904. },
  905. friendly = {
  906. order = 4,
  907. type = "color",
  908. name = L["Friendly"],
  909. desc = L["Health bar color for friendly units."],
  910. arg = "healthColors.friendly",
  911. },
  912. neutral = {
  913. order = 5,
  914. type = "color",
  915. name = L["Neutral"],
  916. desc = L["Health bar color for neutral units."],
  917. arg = "healthColors.neutral",
  918. },
  919. hostile = {
  920. order = 6,
  921. type = "color",
  922. name = L["Hostile"],
  923. desc = L["Health bar color for hostile units."],
  924. arg = "healthColors.hostile",
  925. },
  926. static = {
  927. order = 7,
  928. type = "color",
  929. name = L["Static"],
  930. desc = L["Color to use for health bars that are set to be colored by a static color."],
  931. arg = "healthColors.static",
  932. },
  933. inc = {
  934. order = 8,
  935. type = "color",
  936. name = L["Incoming heal"],
  937. desc = L["Health bar color to use to show how much healing someone is about to receive."],
  938. arg = "healthColors.inc",
  939. },
  940. enemyUnattack = {
  941. order = 9,
  942. type = "color",
  943. name = L["Unattackable hostile"],
  944. desc = L["Health bar color to use for hostile units who you cannot attack, used for reaction coloring."],
  945. hidden = hideAdvancedOption,
  946. arg = "healthColors.enemyUnattack",
  947. }
  948. },
  949. },
  950. power = {
  951. order = 2,
  952. type = "group",
  953. inline = true,
  954. name = L["Power"],
  955. set = setColor,
  956. get = getColor,
  957. args = {
  958. MANA = {
  959. order = 0,
  960. type = "color",
  961. name = L["Mana"],
  962. hasAlpha = true,
  963. width = "half",
  964. arg = "powerColors.MANA",
  965. },
  966. RAGE = {
  967. order = 1,
  968. type = "color",
  969. name = L["Rage"],
  970. hasAlpha = true,
  971. width = "half",
  972. arg = "powerColors.RAGE",
  973. },
  974. FOCUS = {
  975. order = 2,
  976. type = "color",
  977. name = L["Focus"],
  978. hasAlpha = true,
  979. arg = "powerColors.FOCUS",
  980. width = "half",
  981. },
  982. ENERGY = {
  983. order = 3,
  984. type = "color",
  985. name = L["Energy"],
  986. hasAlpha = true,
  987. arg = "powerColors.ENERGY",
  988. width = "half",
  989. },
  990. RUNIC_POWER = {
  991. order = 6,
  992. type = "color",
  993. name = L["Runic Power"],
  994. hasAlpha = true,
  995. arg = "powerColors.RUNIC_POWER",
  996. },
  997. ECLIPSE_MOON = {
  998. order = 7,
  999. type = "color",
  1000. name = L["Eclipse (Moon)"],
  1001. desc = L["Bar coloring for the moon portion of the eclipse bar."],
  1002. hidden = function(info) return select(2, UnitClass("player")) ~= "DRUID" end,
  1003. hasAlpha = true,
  1004. arg = "powerColors.ECLIPSE_MOON",
  1005. },
  1006. ECLIPSE_SUN = {
  1007. order = 8,
  1008. type = "color",
  1009. name = L["Eclipse (Sun)"],
  1010. desc = L["Bar coloring for the moon portion of the eclipse bar."],
  1011. hidden = function(info) return select(2, UnitClass("player")) ~= "DRUID" end,
  1012. hasAlpha = true,
  1013. arg = "powerColors.ECLIPSE_SUN",
  1014. },
  1015. AMMOSLOT = {
  1016. order = 9,
  1017. type = "color",
  1018. name = L["Ammo"],
  1019. hasAlpha = true,
  1020. arg = "powerColors.AMMOSLOT",
  1021. hidden = hideAdvancedOption,
  1022. },
  1023. FUEL = {
  1024. order = 10,
  1025. type = "color",
  1026. name = L["Fuel"],
  1027. hasAlpha = true,
  1028. arg = "powerColors.FUEL",
  1029. hidden = hideAdvancedOption,
  1030. },
  1031. COMBOPOINTS = {
  1032. order = 11,
  1033. type = "color",
  1034. name = L["Combo points"],
  1035. hasAlpha = true,
  1036. arg = "powerColors.COMBOPOINTS",
  1037. },
  1038. HOLYPOWER = {
  1039. order = 12,
  1040. type = "color",
  1041. name = L["Holy Power"],
  1042. hasAlpha = true,
  1043. arg = "powerColors.HOLYPOWER",
  1044. hidden = function(info) return select(2, UnitClass("player")) ~= "PALADIN" end,
  1045. },
  1046. SOULSHARDS = {
  1047. order = 13,
  1048. type = "color",
  1049. name = L["Soul Shards"],
  1050. hasAlpha = true,
  1051. arg = "powerColors.SOULSHARDS",
  1052. hidden = function(info) return select(2, UnitClass("player")) ~= "WARLOCK" end,
  1053. },
  1054. },
  1055. },
  1056. cast = {
  1057. order = 3,
  1058. type = "group",
  1059. inline = true,
  1060. name = L["Cast"],
  1061. set = setColor,
  1062. get = getColor,
  1063. args = {
  1064. cast = {
  1065. order = 0,
  1066. type = "color",
  1067. name = L["Casting"],
  1068. desc = L["Color used when an unit is casting a spell."],
  1069. arg = "castColors.cast",
  1070. },
  1071. channel = {
  1072. order = 1,
  1073. type = "color",
  1074. name = L["Channelling"],
  1075. desc = L["Color used when a cast is a channel."],
  1076. arg = "castColors.channel",
  1077. },
  1078. sep = {
  1079. order = 2,
  1080. type = "description",
  1081. name = "",
  1082. hidden = hideAdvancedOption,
  1083. width = "full",
  1084. },
  1085. finished = {
  1086. order = 3,
  1087. type = "color",
  1088. name = L["Finished cast"],
  1089. desc = L["Color used when a cast is successfully finished."],
  1090. hidden = hideAdvancedOption,
  1091. arg = "castColors.finished",
  1092. },
  1093. interrupted = {
  1094. order = 4,
  1095. type = "color",
  1096. name = L["Cast interrupted"],
  1097. desc = L["Color used when a cast is interrupted either by the caster themselves or by another unit."],
  1098. hidden = hideAdvancedOption,
  1099. arg = "castColors.interrupted",
  1100. },
  1101. uninterruptible = {
  1102. order = 5,
  1103. type = "color",
  1104. name = L["Cast uninterruptible"],
  1105. desc = L["Color used when a cast cannot be interrupted, this is only used for PvE mobs."],
  1106. arg = "castColors.uninterruptible",
  1107. },
  1108. },
  1109. },
  1110. auras = {
  1111. order = 3.5,
  1112. type = "group",
  1113. inline = true,
  1114. name = L["Aura borders"],
  1115. set = setColor,
  1116. get = getColor,
  1117. hidden = hideAdvancedOption,
  1118. args = {
  1119. removableColor = {
  1120. order = 0,
  1121. type = "color",
  1122. name = L["Stealable or Removable"],
  1123. desc = L["Border coloring of stealable or removable auras."],
  1124. arg = "auraColors.removable",
  1125. }
  1126. }
  1127. },
  1128. classColors = {
  1129. order = 4,
  1130. type = "group",
  1131. inline = true,
  1132. name = L["Classes"],
  1133. set = setColor,
  1134. get = getColor,
  1135. args = {}
  1136. },
  1137. },
  1138. },
  1139. profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(ShadowUF.db, true),
  1140. text = {
  1141. type = "group",
  1142. order = 6,
  1143. name = L["Text management"],
  1144. hidden = false,
  1145. args = {
  1146. help = {
  1147. order = 0,
  1148. type = "group",
  1149. inline = true,
  1150. name = L["Help"],
  1151. args = {
  1152. help = {
  1153. order = 0,
  1154. type = "description",
  1155. 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."],
  1156. },
  1157. },
  1158. },
  1159. add = {
  1160. order = 1,
  1161. name = L["Add new text"],
  1162. inline = true,
  1163. type = "group",
  1164. set = function(info, value) textData[info[#(info)] ] = value end,
  1165. get = function(info, value) return textData[info[#(info)] ] end,
  1166. args = {
  1167. name = {
  1168. order = 0,
  1169. type = "input",
  1170. name = L["Text name"],
  1171. desc = L["Text name that you can use to identify this text from others when configuring."],
  1172. },
  1173. parent = {
  1174. order = 1,
  1175. type = "select",
  1176. name = L["Text parent"],
  1177. desc = L["Where inside the frame the text should be anchored to."],
  1178. values = barModules,
  1179. },
  1180. add = {
  1181. order = 2,
  1182. type = "execute",
  1183. name = L["Add"],
  1184. disabled = function() return not textData.name or textData.name == "" or not textData.parent end,
  1185. func = function(info)
  1186. -- Verify we entered a good name
  1187. textData.name = string.trim(textData.name)
  1188. textData.name = textData.name ~= "" and textData.name or nil
  1189. -- Add the new entry
  1190. for _, unit in pairs(ShadowUF.unitList) do
  1191. 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})
  1192. end
  1193. -- Add it to the GUI
  1194. local id = tostring(#(ShadowUF.db.profile.units.player.text))
  1195. addTextParent.args[id .. ":label"] = addTextLabel
  1196. addTextParent.args[id] = addText
  1197. addTextParent.args[id .. ":sep"] = addTextSep
  1198. options.args.general.args.text.args[textData.parent] = options.args.general.args.text.args[textData.parent] or addTextParent
  1199. local parent = string.sub(textData.parent, 2)
  1200. Config.tagWizard[parent] = Config.tagWizard[parent] or Config.parentTable
  1201. Config.tagWizard[parent].args[id] = Config.tagTextTable
  1202. Config.tagWizard[parent].args[id .. ":adv"] = Config.advanceTextTable
  1203. quickIDMap[id .. ":adv"] = #(ShadowUF.db.profile.units.player.text)
  1204. -- Reset
  1205. textData.name = nil
  1206. textData.parent = nil
  1207. end,
  1208. },
  1209. },
  1210. },
  1211. },
  1212. },
  1213. layout = layoutManager,
  1214. },
  1215. }
  1216. -- Load text
  1217. for id, text in pairs(ShadowUF.db.profile.units.player.text) do
  1218. addTextParent.args[id .. ":label"] = addTextLabel
  1219. addTextParent.args[tostring(id)] = addText
  1220. addTextParent.args[id .. ":sep"] = addTextSep
  1221. options.args.general.args.text.args[text.anchorTo] = addTextParent
  1222. end
  1223. Config.classTable = {
  1224. order = 0,
  1225. type = "color",
  1226. name = getName,
  1227. hasAlpha = true,
  1228. width = "half",
  1229. arg = "classColors.$key",
  1230. }
  1231. for classToken in pairs(RAID_CLASS_COLORS) do
  1232. options.args.general.args.color.args.classColors.args[classToken] = Config.classTable
  1233. end
  1234. options.args.general.args.color.args.classColors.args.PET = Config.classTable
  1235. options.args.general.args.color.args.classColors.args.VEHICLE = Config.classTable
  1236. options.args.general.args.profile.order = 4
  1237. end
  1238. ---------------------
  1239. -- HIDE BLIZZARD FRAMES CONFIGURATION
  1240. ---------------------
  1241. local function loadHideOptions()
  1242. Config.hideTable = {
  1243. order = function(info) return info[#(info)] == "buffs" and 1 or 2 end,
  1244. type = "toggle",
  1245. name = function(info)
  1246. local key = info[#(info)]
  1247. 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"])
  1248. end,
  1249. set = function(info, value)
  1250. set(info, value)
  1251. if( value ) then ShadowUF:HideBlizzardFrames() end
  1252. end,
  1253. hidden = false,
  1254. get = get,
  1255. arg = "hidden.$key",
  1256. }
  1257. options.args.hideBlizzard = {
  1258. type = "group",
  1259. name = L["Hide Blizzard"],
  1260. desc = getPageDescription,
  1261. args = {
  1262. help = {
  1263. order = 0,
  1264. type = "group",
  1265. name = L["Help"],
  1266. inline = true,
  1267. args = {
  1268. description = {
  1269. type = "description",
  1270. 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."],
  1271. width = "full",
  1272. },
  1273. },
  1274. },
  1275. hide = {
  1276. order = 1,
  1277. type = "group",
  1278. name = L["Frames"],
  1279. inline = true,
  1280. args = {
  1281. buffs = Config.hideTable,
  1282. cast = Config.hideTable,
  1283. runes = Config.hideTable,
  1284. party = Config.hideTable,
  1285. raid = Config.hideTable,
  1286. player = Config.hideTable,
  1287. pet = Config.hideTable,
  1288. target = Config.hideTable,
  1289. focus = Config.hideTable,
  1290. boss = Config.hideTable,
  1291. arena = Config.hideTable,
  1292. playerAltPower = Config.hideTable,
  1293. },
  1294. },
  1295. }
  1296. }
  1297. end
  1298. ---------------------
  1299. -- UNIT CONFIGURATION
  1300. ---------------------
  1301. local function loadUnitOptions()
  1302. -- This makes sure we don't end up with any messed up positioning due to two different anchors being used
  1303. local function fixPositions(info)
  1304. local unit = info[2]
  1305. local key = info[#(info)]
  1306. if( key == "point" or key == "relativePoint" ) then
  1307. ShadowUF.db.profile.positions[unit].anchorPoint = ""
  1308. ShadowUF.db.profile.positions[unit].movedAnchor = nil
  1309. elseif( key == "anchorPoint" ) then
  1310. ShadowUF.db.profile.positions[unit].point = ""
  1311. ShadowUF.db.profile.positions[unit].relativePoint = ""
  1312. end
  1313. -- Reset offset if it was a manually positioned frame, and it got anchored
  1314. -- Why 100/-100 you ask? Because anything else requires some sort of logic applied to it
  1315. -- and this means the frames won't directly overlap too which is a nice bonus
  1316. if( key == "anchorTo" ) then
  1317. ShadowUF.db.profile.positions[unit].x = 100
  1318. ShadowUF.db.profile.positions[unit].y = -100
  1319. end
  1320. end
  1321. -- Hide raid option in party config
  1322. local function hideRaidOrAdvancedOption(info)
  1323. if( info[2] == "party" and ShadowUF.db.profile.advanced ) then return false end
  1324. return info[2] ~= "raid" and info[2] ~= "raidpet" and info[2] ~= "maintank" and info[2] ~= "mainassist"
  1325. end
  1326. local function hideRaidOption(info)
  1327. return info[2] ~= "raid" and info[2] ~= "raidpet" and info[2] ~= "maintank" and info[2] ~= "mainassist"
  1328. end
  1329. local function hideSplitOrRaidOption(info)
  1330. if( info[2] == "raid" and ShadowUF.db.profile.units.raid.frameSplit ) then
  1331. return true
  1332. end
  1333. return hideRaidOption(info)
  1334. end
  1335. -- Not every option should be changed via global settings
  1336. local function hideSpecialOptions(info)
  1337. local unit = info[2]
  1338. if( unit == "global" or unit == "partypet" ) then
  1339. return true
  1340. end
  1341. return hideAdvancedOption(info)
  1342. end
  1343. local function checkNumber(info, value)
  1344. return tonumber(value)
  1345. end
  1346. local function setPosition(info, value)
  1347. ShadowUF.db.profile.positions[info[2]][info[#(info)]] = value
  1348. fixPositions(info)
  1349. 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
  1350. ShadowUF.Units:ReloadHeader(info[2])
  1351. else
  1352. ShadowUF.Layout:Reload(info[2])
  1353. end
  1354. end
  1355. l

Large files files are truncated, but you can click here to view the full file