From c66afbf45f32aad61e8a1407c368530b78079517 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Sat, 27 Apr 2019 13:21:07 +0700 Subject: [PATCH 01/20] Exposed L --- core/core.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/core/core.lua b/core/core.lua index 12809c32..c5e00673 100644 --- a/core/core.lua +++ b/core/core.lua @@ -19,6 +19,7 @@ _G[addonName] = { [1] = ns.E, [2] = ns.M, [3] = ns.C, + [4] = ns.L } ------------ From 8894f148c15ad6c4ed4a89e8ded5fb7397393825 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Thu, 2 May 2019 11:16:15 +0700 Subject: [PATCH 02/20] Disable azerite bar at max azerite level --- modules/bars/xpbar.lua | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/bars/xpbar.lua b/modules/bars/xpbar.lua index c4c6a65d..4b3ab103 100644 --- a/modules/bars/xpbar.lua +++ b/modules/bars/xpbar.lua @@ -170,19 +170,21 @@ local function bar_UpdateSegments(self) end -- Azerite - local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem() - if azeriteItemLocation then - index = index + 1 + if not C_AzeriteItem.IsAzeriteItemAtMaxLevel() then + local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem() + if azeriteItemLocation then + index = index + 1 - local cur, max = C_AzeriteItem.GetAzeriteItemXPInfo(azeriteItemLocation) - local level = C_AzeriteItem.GetPowerLevel(azeriteItemLocation) + local cur, max = C_AzeriteItem.GetAzeriteItemXPInfo(azeriteItemLocation) + local level = C_AzeriteItem.GetPowerLevel(azeriteItemLocation) - self[index].tooltipInfo = { - header = L["ARTIFACT_POWER"], - line1 = L["ARTIFACT_LEVEL_TOOLTIP"]:format(level), - } + self[index].tooltipInfo = { + header = L["ARTIFACT_POWER"], + line1 = L["ARTIFACT_LEVEL_TOOLTIP"]:format(level), + } - self[index]:Update(cur, max, 0, C.db.global.colors.white, "Interface\\AddOns\\ls_UI\\assets\\statusbar-azerite-fill") + self[index]:Update(cur, max, 0, C.db.global.colors.white, "Interface\\AddOns\\ls_UI\\assets\\statusbar-azerite-fill") + end end -- XP From 56c4ebb03895c7b8254ab77e68702ab28a6ec620 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Thu, 2 May 2019 11:16:31 +0700 Subject: [PATCH 03/20] =?UTF-8?q?=F0=9F=92=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/bars/xpbar.lua | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/modules/bars/xpbar.lua b/modules/bars/xpbar.lua index 4b3ab103..5af1941c 100644 --- a/modules/bars/xpbar.lua +++ b/modules/bars/xpbar.lua @@ -188,26 +188,24 @@ local function bar_UpdateSegments(self) end -- XP - if UnitLevel("player") < MAX_PLAYER_LEVEL then - if not IsXPUserDisabled() then - index = index + 1 - - local cur, max = UnitXP("player"), UnitXPMax("player") - local bonus = GetXPExhaustion() or 0 + if not IsXPUserDisabled() and UnitLevel("player") < MAX_PLAYER_LEVEL then + index = index + 1 - self[index].tooltipInfo = { - header = L["EXPERIENCE"], - line1 = L["LEVEL_TOOLTIP"]:format(UnitLevel("player")), - } + local cur, max = UnitXP("player"), UnitXPMax("player") + local bonus = GetXPExhaustion() or 0 - if bonus > 0 then - self[index].tooltipInfo.line2 = L["BONUS_XP_TOOLTIP"]:format(BreakUpLargeNumbers(bonus)) - else - self[index].tooltipInfo.line2 = nil - end + self[index].tooltipInfo = { + header = L["EXPERIENCE"], + line1 = L["LEVEL_TOOLTIP"]:format(UnitLevel("player")), + } - self[index]:Update(cur, max, bonus, bonus > 0 and C.db.profile.colors.xp[1] or C.db.profile.colors.xp[2]) + if bonus > 0 then + self[index].tooltipInfo.line2 = L["BONUS_XP_TOOLTIP"]:format(BreakUpLargeNumbers(bonus)) + else + self[index].tooltipInfo.line2 = nil end + + self[index]:Update(cur, max, bonus, bonus > 0 and C.db.profile.colors.xp[1] or C.db.profile.colors.xp[2]) end -- Honour From 9e87ff2aca0bf5a614a2cf5019c782cd034e6128 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Tue, 7 May 2019 15:44:26 +0700 Subject: [PATCH 04/20] Add tag editing --- config/core.lua | 40 +++ config/general.lua | 475 +++++++++++++++++++++++++++++++++++- core/defaults.lua | 2 + embeds/oUF | 2 +- locales/enUS.lua | 15 ++ modules/unitframes/core.lua | 20 ++ 6 files changed, 550 insertions(+), 4 deletions(-) diff --git a/config/core.lua b/config/core.lua index 5d623407..7dae9891 100644 --- a/config/core.lua +++ b/config/core.lua @@ -4,7 +4,9 @@ local MODULE = P:AddModule("Config") -- Lua local _G = getfenv(0) +local loadstring = _G.loadstring local next = _G.next +local pcall = _G.pcall local t_concat = _G.table.concat local t_insert = _G.table.insert local t_sort = _G.table.sort @@ -613,6 +615,44 @@ do end end +-- MODULE.IsEventStringValid +do + local badEvents = {} + local validator = CreateFrame("Frame") + + function MODULE:IsEventStringValid(eventString) + t_wipe(badEvents) + + for event in eventString:gmatch('%S+') do + if not pcall(validator.RegisterEvent, validator, event) then + t_insert(badEvents, "|cffffffff" .. event .. "|r") + end + end + + return #badEvents > 0 and L["INVALID_EVENTS_ERR"]:format(t_concat(badEvents, ", ")) or true + end +end + +-- MODULE.IsVarStringValid +do + function MODULE:IsVarStringValid(varString) + if tonumber(varString) then + return true + else + local _, err = loadstring("return " .. varString) + return err and L["LUA_ERROR"]:format("|cffffffff" .. err .. "|r") or true + end + end +end + +-- MODULE.IsFuncStringValid +do + function MODULE:IsFuncStringValid(funcString) + local _, err = loadstring("return " .. funcString) + return err and L["LUA_ERROR"]:format("|cffffffff" .. err .. "|r") or true + end +end + function MODULE:CopySettings(src, dest, ignoredKeys) for k, v in next, dest do if not ignoredKeys or not ignoredKeys[k] then diff --git a/config/general.lua b/config/general.lua index dfda2cd2..651f8a0d 100644 --- a/config/general.lua +++ b/config/general.lua @@ -1,5 +1,5 @@ local _, ns = ... -local E, C, M, L, P, D = ns.E, ns.C, ns.M, ns.L, ns.P, ns.D +local E, C, M, L, P, D, oUF = ns.E, ns.C, ns.M, ns.L, ns.P, ns.D, ns.oUF local CONFIG = P:GetModule("Config") local BARS = P:GetModule("Bars") local MINIMAP = P:GetModule("Minimap") @@ -8,18 +8,467 @@ local BLIZZARD = P:GetModule("Blizzard") -- Lua local _G = getfenv(0) -local tonumber = _G.tonumber local next = _G.next +local rawset = _G.rawset +local s_trim = _G.string.trim +local t_insert = _G.table.insert +local t_sort = _G.table.sort +local t_wipe = _G.table.wipe +local tonumber = _G.tonumber +local tostring = _G.tostring local type = _G.type --[[ luacheck: globals - GetText UnitSex + GetText LibStub UnitSex FACTION_STANDING_LABEL1 FACTION_STANDING_LABEL2 FACTION_STANDING_LABEL3 FACTION_STANDING_LABEL4 FACTION_STANDING_LABEL5 FACTION_STANDING_LABEL6 FACTION_STANDING_LABEL7 FACTION_STANDING_LABEL8 ]] -- Mine +local AceConfigDialog = LibStub("AceConfigDialog-3.0") + +local updateTagOptions +do + local function isDefaultTag(info) + return D.global.tags[info[#info - 1]] + end + + local function validateTagEvents(_, value) + CONFIG:SetStatusText("") + return CONFIG:IsEventStringValid(value) + end + + local function validateTagVars(_, value) + CONFIG:SetStatusText("") + return CONFIG:IsVarStringValid(value) + end + + local function validateTagFunc(_, value) + CONFIG:SetStatusText("") + return CONFIG:IsFuncStringValid(value) + end + + local curTagInfo = { + name = { + order = 1, + type = "input", + width = "full", + name = L["NAME"], + disabled = isDefaultTag, + validate = function(info, value) + value = s_trim(value) + + CONFIG:SetStatusText("") + return (value ~= info[#info - 1] and oUF.Tags.Methods[value]) and L["NAME_TAKEN_ERR"] or true + end, + get = function(info) + return info[#info - 1] + end, + set = function(info, value) + value = s_trim(value) + if value ~= "" and value ~= info[#info - 1] then + if not C.db.global.tags[value] then + C.db.global.tags[value] = C.db.global.tags[info[#info - 1]] + C.db.global.tags[info[#info - 1]] = nil + + oUF.Tags.Events[value] = C.db.global.tags[value].events + oUF.Tags.Events[info[#info - 1]] = nil + + rawset(oUF.Tags.Vars, info[#info - 1], nil) + oUF.Tags.Vars[value] = C.db.global.tags[value].vars + + rawset(oUF.Tags.Methods, info[#info - 1], nil) + oUF.Tags.Methods[value] = C.db.global.tags[value].func + + updateTagOptions() + + AceConfigDialog:SelectGroup("ls_UI", "general", "tags", value) + end + end + end, + }, + events = { + order = 2, + type = "input", + width = "full", + name = L["EVENTS"], + validate = validateTagEvents, + set = function(info, value) + value = s_trim(value) + if value ~= "" and C.db.global.tags[info[#info - 1]].events ~= value then + C.db.global.tags[info[#info - 1]].events = value + + oUF.Tags.Events[info[#info - 1]] = value + + oUF.Tags:RefreshEvents(info[#info - 1]) + end + end, + }, + vars = { + order = 3, + type = "input", + width = "full", + name = L["VAR"], + multiline = 8, + disabled = isDefaultTag, + validate = validateTagVars, + set = function(info, value) + value = tonumber(value) or s_trim(value) + if value ~= "" and C.db.global.tags[info[#info - 1]].vars ~= value then + C.db.global.tags[info[#info - 1]].vars = value + + rawset(oUF.Tags.Vars, info[#info - 1], nil) + oUF.Tags.Vars[info[#info - 1]] = value + end + end, + }, + func = { + order = 4, + type = "input", + width = "full", + name = L["FUNC"], + multiline = 16, + validate = validateTagFunc, + set = function(info, value) + value = s_trim(value) + if C.db.global.tags[info[#info - 1]].func ~= value then + C.db.global.tags[info[#info - 1]].func = value + + rawset(oUF.Tags.Methods, info[#info - 1], nil) + oUF.Tags.Methods[info[#info - 1]] = value + + oUF.Tags:RefreshMethods(info[#info - 1]) + end + end, + }, + delete = { + order = 5, + type = "execute", + name = L["DELETE"], + width = "full", + disabled = isDefaultTag, + func = function(info) + C.db.global.tags[info[#info - 1]] = nil + oUF.Tags.Events[info[#info - 1]] = nil + rawset(oUF.Tags.Vars, info[#info - 1], nil) + rawset(oUF.Tags.Methods, info[#info - 1], nil) + + updateTagOptions() + + AceConfigDialog:SelectGroup("ls_UI", "general", "tags") + end, + }, + } + + local newTagInfo = { + name = "", + events = "", + vars = "", + func = "", + } + + local tagOptionTables = { + new = { + order = 1, + type = "group", + name = L["NEW_TAG"], + get = function(info) + return tostring(newTagInfo[info[#info]]) + end, + set = function(info, value) + newTagInfo[info[#info]] = s_trim(value) + end, + args = { + name = { + order = 1, + type = "input", + width = "full", + name = L["NAME"], + validate = function(_, value) + value = s_trim(value) + + CONFIG:SetStatusText("") + return oUF.Tags.Methods[value] and L["NAME_TAKEN_ERR"] or true + end, + }, + events = { + order = 2, + type = "input", + width = "full", + name = L["EVENTS"], + validate = validateTagEvents, + }, + vars = { + order = 3, + type = "input", + width = "full", + name = L["VAR"], + multiline = 8, + validate = validateTagVars, + set = function(_, value) + newTagInfo.vars = tonumber(value) or s_trim(value) + end, + }, + func = { + order = 4, + type = "input", + width = "full", + name = L["FUNC"], + multiline = 16, + validate = validateTagFunc, + }, + add = { + order = 5, + type = "execute", + name = L["ADD"], + width = "full", + func = function() + if newTagInfo.name ~= "" and newTagInfo.func ~= "" then + C.db.global.tags[newTagInfo.name] = {} + + if newTagInfo.events ~= "" then + C.db.global.tags[newTagInfo.name].events = newTagInfo.events + oUF.Tags.Events[newTagInfo.name] = newTagInfo.events + end + + if newTagInfo.vars ~= "" then + C.db.global.tags[newTagInfo.name].vars = newTagInfo.vars + oUF.Tags.Vars[newTagInfo.name] = newTagInfo.vars + end + + C.db.global.tags[newTagInfo.name].func = newTagInfo.func + oUF.Tags.Methods[newTagInfo.name] = newTagInfo.func + + updateTagOptions() + + AceConfigDialog:SelectGroup("ls_UI", "general", "tags", newTagInfo.name) + + newTagInfo.name = "" + newTagInfo.events = "" + newTagInfo.vars = "" + newTagInfo.func = "" + end + end, + }, + }, + }, + } + + local order = {} + + function updateTagOptions() + local options = C.options.args.general.args.tags.args + + t_wipe(options) + t_wipe(order) + + options.new = tagOptionTables.new + + for tag in next, C.db.global.tags do + if not tagOptionTables[tag] then + tagOptionTables[tag] = { + type = "group", + name = tag, + args = curTagInfo, + } + end + + options[tag] = tagOptionTables[tag] + + t_insert(order, tag) + end + + t_sort(order) + + for i, tag in next, order do + if options[tag] then + options[tag].order = i + 10 + end + end + end +end + +local updateTagVarsOptions +do + local function isDefaultTag(info) + return D.global.tags[info[#info - 1]] + end + + local function validateTagVars(_, value) + CONFIG:SetStatusText("") + return CONFIG:IsVarStringValid(value) + end + + local curVarInfo = { + name = { + order = 1, + type = "input", + width = "full", + name = L["NAME"], + disabled = isDefaultTag, + validate = function(info, value) + value = s_trim(value) + + CONFIG:SetStatusText("") + return (value ~= info[#info - 1] and oUF.Tags.Vars[value]) and L["NAME_TAKEN_ERR"] or true + end, + get = function(info) + return info[#info - 1] + end, + set = function(info, value) + value = s_trim(value) + if value ~= "" and value ~= info[#info - 1] then + if not C.db.global.tag_vars[value] then + C.db.global.tag_vars[value] = C.db.global.tag_vars[info[#info - 1]] + C.db.global.tag_vars[info[#info - 1]] = nil + + oUF.Tags.Vars[value] = C.db.global.tag_vars[value].vars + rawset(oUF.Tags.Vars, info[#info - 1], nil) + + updateTagVarsOptions() + + AceConfigDialog:SelectGroup("ls_UI", "general", "tag_vars", value) + end + end + end, + }, + value = { + order = 2, + type = "input", + width = "full", + name = L["VALUE"], + multiline = 16, + disabled = isDefaultTag, + validate = validateTagVars, + get = function(info) + return tostring(C.db.global.tag_vars[info[#info - 1]]) + end, + set = function(info, value) + value = tonumber(value) or s_trim(value) + if value ~= "" and C.db.global.tag_vars[info[#info - 1]] ~= value then + C.db.global.tag_vars[info[#info - 1]] = value + + rawset(oUF.Tags.Vars, info[#info - 1], nil) + oUF.Tags.Vars[info[#info - 1]] = value + end + end, + }, + delete = { + order = 3, + type = "execute", + name = L["DELETE"], + width = "full", + disabled = isDefaultTag, + func = function(info) + C.db.global.tag_vars[info[#info - 1]] = nil + rawset(oUF.Tags.Vars, info[#info - 1], nil) + + updateTagVarsOptions() + + AceConfigDialog:SelectGroup("ls_UI", "general", "tag_vars") + end, + }, + } + + local newVarInfo = { + name = "", + value = "", + } + + local varOptionTables = { + new = { + order = 1, + type = "group", + name = L["NEW_VAR"], + get = function(info) + return tostring(newVarInfo[info[#info]]) + end, + args = { + name = { + order = 1, + type = "input", + width = "full", + name = L["NAME"], + validate = function(_, value) + value = s_trim(value) + + CONFIG:SetStatusText("") + return oUF.Tags.Vars[value] and L["NAME_TAKEN_ERR"] or true + end, + set = function(_, value) + newVarInfo.name = s_trim(value) + end, + }, + value = { + order = 3, + type = "input", + width = "full", + name = L["VALUE"], + multiline = 16, + validate = validateTagVars, + set = function(_, value) + newVarInfo.value = tonumber(value) or s_trim(value) + end, + }, + add = { + order = 5, + type = "execute", + name = L["ADD"], + width = "full", + func = function() + if newVarInfo.name ~= "" then + C.db.global.tag_vars[newVarInfo.name] = newVarInfo.value + + oUF.Tags.Vars[newVarInfo.name] = newVarInfo.value + + updateTagVarsOptions() + + AceConfigDialog:SelectGroup("ls_UI", "general", "tag_vars", newVarInfo.name) + + newVarInfo.name = "" + newVarInfo.value = "" + end + end, + }, + }, + }, + } + + local order = {} + + function updateTagVarsOptions() + local options = C.options.args.general.args.tag_vars.args + + t_wipe(options) + t_wipe(order) + + options.new = varOptionTables.new + + for var in next, C.db.global.tag_vars do + if not varOptionTables[var] then + varOptionTables[var] = { + type = "group", + name = var, + args = curVarInfo, + } + end + + options[var] = varOptionTables[var] + + t_insert(order, var) + end + + t_sort(order) + + for i, var in next, order do + if options[var] then + options[var].order = i + 10 + end + end + end +end + function CONFIG:CreateGeneralPanel(order) C.options.args.general = { order = order, @@ -1039,6 +1488,26 @@ function CONFIG:CreateGeneralPanel(order) }, }, }, + tags = { + order = 2, + type = "group", + childGroups = "tree", + name = L["TAGS"], + get = function(info) + return tostring(C.db.global.tags[info[#info - 1]][info[#info]] or "") + end, + args = {}, + }, + tag_vars = { + order = 3, + type = "group", + childGroups = "tree", + name = L["TAG_VARS"], + args = {}, + }, }, } + + updateTagOptions() + updateTagVarsOptions() end diff --git a/core/defaults.lua b/core/defaults.lua index c485aaa3..693d0992 100644 --- a/core/defaults.lua +++ b/core/defaults.lua @@ -62,6 +62,8 @@ D.global = { [3] = rgb(46, 172, 52), -- #2EAC34 (10GY 6/12) }, }, + tags = {}, + tag_vars = {}, } D.profile = { diff --git a/embeds/oUF b/embeds/oUF index 6360c6ab..b681f7b7 160000 --- a/embeds/oUF +++ b/embeds/oUF @@ -1 +1 @@ -Subproject commit 6360c6ab3aa3852e24e9968922ec3f54c233aa27 +Subproject commit b681f7b73d32cf9b579e9951cd9c3a378e78fef3 diff --git a/locales/enUS.lua b/locales/enUS.lua index bb450bc3..351320d3 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -8,6 +8,7 @@ local _G = getfenv(0) L["LS_UI"] = "ls: |cff1a9fc0UI|r" -- These rely on Blizz strings +L["ADD"] = _G.ADD L["ARCANE_CHARGES"] = _G.POWER_TYPE_ARCANE_CHARGES L["CALENDAR_EVENT_ALARM_MESSAGE"] = _G.CALENDAR_EVENT_ALARM_MESSAGE L["CALENDAR_PENDING_INVITES_TOOLTIP"] = _G.GAMETIME_TOOLTIP_CALENDAR_INVITES @@ -23,6 +24,7 @@ L["CONTESTED_TERRITORY"] = _G.CONTESTED_TERRITORY:gsub("[()]", "") L["CURRENCY"] = _G.CURRENCY L["CURRENCY_COLON"] = _G.CURRENCY..":" L["DAMAGER_RED"] = E:WrapText(D.global.colors.red, _G.DAMAGER) +L["DELETE"] = _G.DELETE L["DURABILITY_COLON"] = _G.DURABILITY..":" L["ENABLE"] = _G.ENABLE L["ENERGY"] = _G.ENERGY @@ -40,6 +42,7 @@ L["HIDE"] = _G.HIDE L["HOLY_POWER"] = _G.HOLY_POWER L["INSANITY"] = _G.INSANITY L["LOOT"] = _G.LOOT_NOUN +L["LUA_ERROR"] = _G.LUA_ERROR ..": %s" L["LUNAR_POWER"] = _G.LUNAR_POWER L["MAELSTROM"] = _G.MAELSTROM L["MAIL"] = _G.MAIL_LABEL @@ -459,3 +462,15 @@ L["YOUR_HEALING"] = "Your Healing" L["YOURS_FIRST"] = "Yours First" L["ZONE_ABILITY_BUTTON"] = "Zone Ability Button" L["ZONE_TEXT"] = "Zone Text" + +-- new +L["EVENTS"] = "Events" +L["FUNC"] = "Function" +L["INVALID_EVENTS_ERR"] = "Attempted to use invalid events: %s." +L["NAME_TAKEN_ERR"] = "The name is taken." +L["NEW_TAG"] = "New Tag" +L["NEW_VAR"] = "New Variable" +L["TAG_VARS"] = "Tag Variables" +L["TAGS"] = "Tags" +L["VALUE"] = "Value" +L["VAR"] = "Variable" diff --git a/modules/unitframes/core.lua b/modules/unitframes/core.lua index 060dceae..b668e527 100644 --- a/modules/unitframes/core.lua +++ b/modules/unitframes/core.lua @@ -5,6 +5,8 @@ local UF = P:AddModule("UnitFrames") -- Lua local _G = getfenv(0) local next = _G.next +local rawset = _G.rawset +local tonumber = _G.tonumber local type = _G.type local unpack = _G.unpack @@ -151,6 +153,23 @@ function UF:UpdatePowerColors() end end +function UF:UpdateTags() + for name, data in next, C.db.global.tags do + oUF.Tags.Events[name] = data.events + + rawset(oUF.Tags.Methods, name, nil) + oUF.Tags.Methods[name] = data.func + + rawset(oUF.Tags.Vars, name, nil) + oUF.Tags.Vars[name] = tonumber(data.vars) or data.vars + end + + for name, vars in next, C.db.global.tag_vars do + rawset(oUF.Tags.Vars, name, nil) + oUF.Tags.Vars[name] = tonumber(vars) or vars + end +end + function UF:CreateUnitFrame(unit, name) if not units[unit] then if unit == "boss" then @@ -228,6 +247,7 @@ function UF:Init() self:UpdateHealthColors() self:UpdateReactionColors() self:UpdatePowerColors() + self:UpdateTags() oUF:Factory(function() oUF:RegisterStyle("LS", function(frame, unit) From 16956b71545027d293c8834039258ef4b699f288 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Tue, 7 May 2019 15:45:18 +0700 Subject: [PATCH 05/20] Check if C_AzeriteItem.IsAzeriteItemAtMaxLevel actually exists --- modules/bars/xpbar.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/bars/xpbar.lua b/modules/bars/xpbar.lua index 5af1941c..43d8ed68 100644 --- a/modules/bars/xpbar.lua +++ b/modules/bars/xpbar.lua @@ -170,7 +170,7 @@ local function bar_UpdateSegments(self) end -- Azerite - if not C_AzeriteItem.IsAzeriteItemAtMaxLevel() then + if not C_AzeriteItem.IsAzeriteItemAtMaxLevel or not C_AzeriteItem.IsAzeriteItemAtMaxLevel() then local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem() if azeriteItemLocation then index = index + 1 From 2053b20f1077dbbeef158b1b0b502fbedf644ae3 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Tue, 7 May 2019 15:48:39 +0700 Subject: [PATCH 06/20] Remove unnecessary tonumber's --- modules/unitframes/core.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/unitframes/core.lua b/modules/unitframes/core.lua index b668e527..61b82173 100644 --- a/modules/unitframes/core.lua +++ b/modules/unitframes/core.lua @@ -6,7 +6,6 @@ local UF = P:AddModule("UnitFrames") local _G = getfenv(0) local next = _G.next local rawset = _G.rawset -local tonumber = _G.tonumber local type = _G.type local unpack = _G.unpack @@ -161,12 +160,12 @@ function UF:UpdateTags() oUF.Tags.Methods[name] = data.func rawset(oUF.Tags.Vars, name, nil) - oUF.Tags.Vars[name] = tonumber(data.vars) or data.vars + oUF.Tags.Vars[name] = data.vars end for name, vars in next, C.db.global.tag_vars do rawset(oUF.Tags.Vars, name, nil) - oUF.Tags.Vars[name] = tonumber(vars) or vars + oUF.Tags.Vars[name] = vars end end From 3ce02c6d465727b7092f61e8989503e1215f1f7c Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Tue, 7 May 2019 16:38:08 +0700 Subject: [PATCH 07/20] Move colours from D.profile to D.global C.db.profile.colors > C.db.global.colors --- config/general.lua | 156 +++++++++--------- core/cooldown.lua | 12 +- core/defaults.lua | 12 +- core/statusbar.lua | 4 +- core/utils.lua | 20 +-- init.lua | 67 ++++---- modules/auras/auras.lua | 4 +- modules/auratracker/auratracker.lua | 2 +- modules/bars/actionbars.lua | 2 +- modules/bars/petbar.lua | 2 +- modules/bars/stancebar.lua | 6 +- modules/bars/xpbar.lua | 12 +- modules/blizzard/castbar.lua | 10 +- modules/minimap/minimap.lua | 4 +- modules/tooltips/tooltips.lua | 2 +- modules/unitframes/core.lua | 12 +- modules/unitframes/elements/auras.lua | 2 +- modules/unitframes/elements/castbar.lua | 8 +- .../unitframes/elements/classindicator.lua | 2 +- modules/unitframes/elements/classpower.lua | 6 +- modules/unitframes/elements/health.lua | 6 +- modules/unitframes/elements/power.lua | 6 +- modules/unitframes/elements/tags.lua | 10 +- 23 files changed, 187 insertions(+), 180 deletions(-) diff --git a/config/general.lua b/config/general.lua index 651f8a0d..729c2f0b 100644 --- a/config/general.lua +++ b/config/general.lua @@ -482,7 +482,7 @@ function CONFIG:CreateGeneralPanel(order) childGroups = "tree", name = L["COLORS"], get = function(info) - return E:GetRGB(C.db.profile.colors[info[#info]]) + return E:GetRGB(C.db.global.colors[info[#info]]) end, args = { health = { @@ -493,7 +493,7 @@ function CONFIG:CreateGeneralPanel(order) if r ~= nil then info = info[#info] - local color = C.db.profile.colors[info] + local color = C.db.global.colors[info] if color.r ~= r or color.g ~= g or color.g ~= b then E:SetRGB(color, r, g, b) @@ -509,9 +509,9 @@ function CONFIG:CreateGeneralPanel(order) order = 1, name = L["RESTORE_DEFAULTS"], func = function() - E:SetRGB(C.db.profile.colors.health, E:GetRGB(D.profile.colors.health)) - E:SetRGB(C.db.profile.colors.disconnected, E:GetRGB(D.profile.colors.disconnected)) - E:SetRGB(C.db.profile.colors.tapped, E:GetRGB(D.profile.colors.tapped)) + E:SetRGB(C.db.global.colors.health, E:GetRGB(D.profile.colors.health)) + E:SetRGB(C.db.global.colors.disconnected, E:GetRGB(D.profile.colors.disconnected)) + E:SetRGB(C.db.global.colors.tapped, E:GetRGB(D.profile.colors.tapped)) UNITFRAMES:UpdateHealthColors() UNITFRAMES:ForEach("ForElement", "Health", "UpdateColors") @@ -545,7 +545,7 @@ function CONFIG:CreateGeneralPanel(order) type = "group", name = L["POWER"], get = function(info) - return E:GetRGB(C.db.profile.colors.power[info[#info]]) + return E:GetRGB(C.db.global.colors.power[info[#info]]) end, set = function(info, r, g, b) if r ~= nil then @@ -553,19 +553,19 @@ function CONFIG:CreateGeneralPanel(order) local color if info == "RUNES_BLOOD" then - color = C.db.profile.colors.rune[1] + color = C.db.global.colors.rune[1] elseif info == "RUNES_FROST" then - color = C.db.profile.colors.rune[2] + color = C.db.global.colors.rune[2] elseif info == "RUNES_UNHOLY" then - color = C.db.profile.colors.rune[3] + color = C.db.global.colors.rune[3] elseif info == "STAGGER_LOW" then - color = C.db.profile.colors.power.STAGGER[1] + color = C.db.global.colors.power.STAGGER[1] elseif info == "STAGGER_MEDIUM" then - color = C.db.profile.colors.power.STAGGER[2] + color = C.db.global.colors.power.STAGGER[2] elseif info == "STAGGER_HIGH" then - color = C.db.profile.colors.power.STAGGER[3] + color = C.db.global.colors.power.STAGGER[3] else - color = C.db.profile.colors.power[info] + color = C.db.global.colors.power[info] end if color.r ~= r or color.g ~= g or color.g ~= b then @@ -593,16 +593,16 @@ function CONFIG:CreateGeneralPanel(order) if type(k) == "string" then if type(v[1]) == "table" then for i, v_ in next, v do - E:SetRGB(C.db.profile.colors.power[k][i], E:GetRGB(v_)) + E:SetRGB(C.db.global.colors.power[k][i], E:GetRGB(v_)) end else - E:SetRGB(C.db.profile.colors.power[k], E:GetRGB(v)) + E:SetRGB(C.db.global.colors.power[k], E:GetRGB(v)) end end end for k, v in next, D.profile.colors.rune do - E:SetRGB(C.db.profile.colors.rune[k], E:GetRGB(v)) + E:SetRGB(C.db.global.colors.rune[k], E:GetRGB(v)) end UNITFRAMES:UpdatePowerColors() @@ -656,7 +656,7 @@ function CONFIG:CreateGeneralPanel(order) type = "color", name = L["RUNES_BLOOD"], get = function() - return E:GetRGB(C.db.profile.colors.rune[1]) + return E:GetRGB(C.db.global.colors.rune[1]) end, }, RUNES_FROST = { @@ -664,7 +664,7 @@ function CONFIG:CreateGeneralPanel(order) type = "color", name = L["RUNES_FROST"], get = function() - return E:GetRGB(C.db.profile.colors.rune[2]) + return E:GetRGB(C.db.global.colors.rune[2]) end, }, RUNES_UNHOLY = { @@ -672,7 +672,7 @@ function CONFIG:CreateGeneralPanel(order) type = "color", name = L["RUNES_UNHOLY"], get = function() - return E:GetRGB(C.db.profile.colors.rune[3]) + return E:GetRGB(C.db.global.colors.rune[3]) end, }, RUNIC_POWER = { @@ -695,65 +695,65 @@ function CONFIG:CreateGeneralPanel(order) type = "color", name = L["HOLY_POWER"], }, - MAELSTROM = { + ALTERNATE = { order = 23, type = "color", + name = L["ALTERNATIVE_POWER"], + }, + MAELSTROM = { + order = 24, + type = "color", name = L["MAELSTROM"], }, INSANITY = { - order = 24, + order = 25, type = "color", name = L["INSANITY"], }, CHI = { - order = 25, + order = 26, type = "color", name = L["CHI"], }, ARCANE_CHARGES = { - order = 26, + order = 27, type = "color", name = L["ARCANE_CHARGES"], }, FURY = { - order = 27, + order = 28, type = "color", name = L["FURY"], }, PAIN = { - order = 28, + order = 29, type = "color", name = L["PAIN"], }, STAGGER_LOW = { - order = 29, + order = 30, type = "color", name = L["STAGGER_LOW"], get = function() - return E:GetRGB(C.db.profile.colors.power.STAGGER[1]) + return E:GetRGB(C.db.global.colors.power.STAGGER[1]) end, }, STAGGER_MEDIUM = { - order = 30, + order = 31, type = "color", name = L["STAGGER_MEDIUM"], get = function() - return E:GetRGB(C.db.profile.colors.power.STAGGER[2]) + return E:GetRGB(C.db.global.colors.power.STAGGER[2]) end, }, STAGGER_HIGH = { - order = 31, + order = 32, type = "color", name = L["STAGGER_HIGH"], get = function() - return E:GetRGB(C.db.profile.colors.power.STAGGER[3]) + return E:GetRGB(C.db.global.colors.power.STAGGER[3]) end, }, - ALT_POWER = { - order = 32, - type = "color", - name = L["ALTERNATIVE_POWER"], - }, }, }, change = { @@ -762,7 +762,7 @@ function CONFIG:CreateGeneralPanel(order) name = L["CHANGE"], set = function(info, r, g, b) if r ~= nil then - local color = C.db.profile.colors[info[#info]] + local color = C.db.global.colors[info[#info]] if color.r ~= r or color.g ~= g or color.g ~= b then E:SetRGB(color, r, g, b) @@ -780,8 +780,8 @@ function CONFIG:CreateGeneralPanel(order) order = 1, name = L["RESTORE_DEFAULTS"], func = function() - E:SetRGB(C.db.profile.colors.gain, E:GetRGB(D.profile.colors.gain)) - E:SetRGB(C.db.profile.colors.loss, E:GetRGB(D.profile.colors.loss)) + E:SetRGB(C.db.global.colors.gain, E:GetRGB(D.profile.colors.gain)) + E:SetRGB(C.db.global.colors.loss, E:GetRGB(D.profile.colors.loss)) UNITFRAMES:ForEach("ForElement", "Health", "UpdateGainLossColors") UNITFRAMES:ForEach("ForElement", "AdditionalPower", "UpdateGainLossColors") @@ -812,11 +812,11 @@ function CONFIG:CreateGeneralPanel(order) type = "group", name = L["PREDICTION"], get = function(info) - return E:GetRGBA(C.db.profile.colors.prediction[info[#info]]) + return E:GetRGBA(C.db.global.colors.prediction[info[#info]]) end, set = function(info, r, g, b) if r ~= nil then - local color = C.db.profile.colors.prediction[info[#info]] + local color = C.db.global.colors.prediction[info[#info]] if color.r ~= r or color.g ~= g or color.g ~= b then E:SetRGB(color, r, g, b) @@ -832,7 +832,7 @@ function CONFIG:CreateGeneralPanel(order) name = L["RESTORE_DEFAULTS"], func = function() for k, v in next, D.profile.colors.prediction do - E:SetRGB(C.db.profile.colors.prediction[k], E:GetRGB(v)) + E:SetRGB(C.db.global.colors.prediction[k], E:GetRGB(v)) end UNITFRAMES:ForEach("ForElement", "HealthPrediction", "UpdateColors") @@ -881,11 +881,11 @@ function CONFIG:CreateGeneralPanel(order) type = "group", name = L["REACTION"], get = function(info) - return E:GetRGB(C.db.profile.colors.reaction[tonumber(info[#info])]) + return E:GetRGB(C.db.global.colors.reaction[tonumber(info[#info])]) end, set = function(info, r, g, b) if r ~= nil then - local color = C.db.profile.colors.reaction[tonumber(info[#info])] + local color = C.db.global.colors.reaction[tonumber(info[#info])] if color.r ~= r or color.g ~= g or color.g ~= b then E:SetRGB(color, r, g, b) @@ -902,7 +902,7 @@ function CONFIG:CreateGeneralPanel(order) name = L["RESTORE_DEFAULTS"], func = function() for k, v in next, D.profile.colors.reaction do - E:SetRGB(C.db.profile.colors.reaction[k], E:GetRGB(v)) + E:SetRGB(C.db.global.colors.reaction[k], E:GetRGB(v)) end UNITFRAMES:UpdateReactionColors() @@ -962,11 +962,11 @@ function CONFIG:CreateGeneralPanel(order) type = "group", name = L["FACTION"], get = function(info) - return E:GetRGB(C.db.profile.colors.faction[info[#info]]) + return E:GetRGB(C.db.global.colors.faction[info[#info]]) end, set = function(info, r, g, b) if r ~= nil then - local color = C.db.profile.colors.faction[info[#info]] + local color = C.db.global.colors.faction[info[#info]] if color.r ~= r or color.g ~= g or color.g ~= b then E:SetRGB(color, r, g, b) @@ -983,7 +983,7 @@ function CONFIG:CreateGeneralPanel(order) name = L["RESTORE_DEFAULTS"], func = function() for k, v in next, D.profile.colors.faction do - E:SetRGB(C.db.profile.colors.faction[k], E:GetRGB(v)) + E:SetRGB(C.db.global.colors.faction[k], E:GetRGB(v)) end if BARS:HasXPBar() then @@ -1018,11 +1018,11 @@ function CONFIG:CreateGeneralPanel(order) type = "group", name = L["EXPERIENCE"], get = function(info) - return E:GetRGB(C.db.profile.colors.xp[tonumber(info[#info])]) + return E:GetRGB(C.db.global.colors.xp[tonumber(info[#info])]) end, set = function(info, r, g, b) if r ~= nil then - local color = C.db.profile.colors.xp[tonumber(info[#info])] + local color = C.db.global.colors.xp[tonumber(info[#info])] if color.r ~= r or color.g ~= g or color.g ~= b then E:SetRGB(color, r, g, b) @@ -1039,11 +1039,11 @@ function CONFIG:CreateGeneralPanel(order) name = L["RESTORE_DEFAULTS"], func = function() for k, v in next, D.profile.colors.xp do - E:SetRGB(C.db.profile.colors.xp[k], E:GetRGB(v)) + E:SetRGB(C.db.global.colors.xp[k], E:GetRGB(v)) end - E:SetRGB(C.db.profile.colors.artifact, E:GetRGB(D.profile.colors.artifact)) - E:SetRGB(C.db.profile.colors.honor, E:GetRGB(D.profile.colors.honor)) + E:SetRGB(C.db.global.colors.artifact, E:GetRGB(D.profile.colors.artifact)) + E:SetRGB(C.db.global.colors.honor, E:GetRGB(D.profile.colors.honor)) if BARS:HasXPBar() then BARS:GetBar("xpbar"):UpdateSegments() @@ -1070,11 +1070,11 @@ function CONFIG:CreateGeneralPanel(order) type = "color", name = L["ARTIFACT_POWER"], get = function() - return E:GetRGB(C.db.profile.colors.artifact) + return E:GetRGB(C.db.global.colors.artifact) end, set = function(_, r, g, b) if r ~= nil then - local color = C.db.profile.colors.artifact + local color = C.db.global.colors.artifact if color.r ~= r or color.g ~= g or color.g ~= b then E:SetRGB(color, r, g, b) @@ -1090,11 +1090,11 @@ function CONFIG:CreateGeneralPanel(order) type = "color", name = L["HONOR"], get = function() - return E:GetRGB(C.db.profile.colors.honor) + return E:GetRGB(C.db.global.colors.honor) end, set = function(_, r, g, b) if r ~= nil then - local color = C.db.profile.colors.honor + local color = C.db.global.colors.honor if color.r ~= r or color.g ~= g or color.g ~= b then E:SetRGB(color, r, g, b) @@ -1112,11 +1112,11 @@ function CONFIG:CreateGeneralPanel(order) type = "group", name = L["DIFFICULTY"], get = function(info) - return E:GetRGB(C.db.profile.colors.difficulty[info[#info]]) + return E:GetRGB(C.db.global.colors.difficulty[info[#info]]) end, set = function(info, r, g, b) if r ~= nil then - local color = C.db.profile.colors.difficulty[info[#info]] + local color = C.db.global.colors.difficulty[info[#info]] if color.r ~= r or color.g ~= g or color.g ~= b then E:SetRGB(color, r, g, b) end @@ -1131,7 +1131,7 @@ function CONFIG:CreateGeneralPanel(order) name = L["RESTORE_DEFAULTS"], func = function() for k, v in next, D.profile.colors.difficulty do - E:SetRGB(C.db.profile.colors.difficulty[k], E:GetRGB(v)) + E:SetRGB(C.db.global.colors.difficulty[k], E:GetRGB(v)) end UNITFRAMES:ForEach("ForElement", "Name", "UpdateTags") @@ -1174,11 +1174,11 @@ function CONFIG:CreateGeneralPanel(order) type = "group", name = L["CASTBAR"], get = function(info) - return E:GetRGB(C.db.profile.colors.castbar[info[#info]]) + return E:GetRGB(C.db.global.colors.castbar[info[#info]]) end, set = function(info, r, g, b) if r ~= nil then - local color = C.db.profile.colors.castbar[info[#info]] + local color = C.db.global.colors.castbar[info[#info]] if color.r ~= r or color.g ~= g or color.g ~= b then E:SetRGB(color, r, g, b) end @@ -1193,7 +1193,7 @@ function CONFIG:CreateGeneralPanel(order) name = L["RESTORE_DEFAULTS"], func = function() for k, v in next, D.profile.colors.castbar do - E:SetRGB(C.db.profile.colors.castbar[k], E:GetRGB(v)) + E:SetRGB(C.db.global.colors.castbar[k], E:GetRGB(v)) end BLIZZARD:UpdateCastBarColors() @@ -1231,11 +1231,11 @@ function CONFIG:CreateGeneralPanel(order) type = "group", name = L["AURA"], get = function(info) - return E:GetRGB(C.db.profile.colors.debuff[info[#info]]) + return E:GetRGB(C.db.global.colors.debuff[info[#info]]) end, set = function(info, r, g, b) if r ~= nil then - local color = C.db.profile.colors.debuff[info[#info]] + local color = C.db.global.colors.debuff[info[#info]] if color.r ~= r or color.g ~= g or color.g ~= b then E:SetRGB(color, r, g, b) end @@ -1250,11 +1250,11 @@ function CONFIG:CreateGeneralPanel(order) name = L["RESTORE_DEFAULTS"], func = function() for k, v in next, D.profile.colors.debuff do - E:SetRGB(C.db.profile.colors.debuff[k], E:GetRGB(v)) + E:SetRGB(C.db.global.colors.debuff[k], E:GetRGB(v)) end for k, v in next, D.profile.colors.buff do - E:SetRGB(C.db.profile.colors.buff[k], E:GetRGB(v)) + E:SetRGB(C.db.global.colors.buff[k], E:GetRGB(v)) end UNITFRAMES:ForEach("ForElement", "Auras", "UpdateColors") @@ -1295,11 +1295,11 @@ function CONFIG:CreateGeneralPanel(order) type = "color", name = L["TEMP_ENCHANT"], get = function() - return E:GetRGB(C.db.profile.colors.buff.Enchant) + return E:GetRGB(C.db.global.colors.buff.Enchant) end, set = function(_, r, g, b) if r ~= nil then - local color = C.db.profile.colors.buff.Enchant + local color = C.db.global.colors.buff.Enchant if color.r ~= r or color.g ~= g or color.g ~= b then E:SetRGB(color, r, g, b) end @@ -1313,11 +1313,11 @@ function CONFIG:CreateGeneralPanel(order) type = "group", name = L["BUTTON"], get = function(info) - return E:GetRGB(C.db.profile.colors.button[info[#info]]) + return E:GetRGB(C.db.global.colors.button[info[#info]]) end, set = function(info, r, g, b) if r ~= nil then - local color = C.db.profile.colors.button[info[#info]] + local color = C.db.global.colors.button[info[#info]] if color.r ~= r or color.g ~= g or color.g ~= b then E:SetRGB(color, r, g, b) end @@ -1332,7 +1332,7 @@ function CONFIG:CreateGeneralPanel(order) name = L["RESTORE_DEFAULTS"], func = function() for k, v in next, D.profile.colors.button do - E:SetRGB(C.db.profile.colors.button[k], E:GetRGB(v)) + E:SetRGB(C.db.global.colors.button[k], E:GetRGB(v)) end BARS:ForEach("UpdateButtonConfig") @@ -1370,11 +1370,11 @@ function CONFIG:CreateGeneralPanel(order) type = "group", name = L["COOLDOWN"], get = function(info) - return E:GetRGB(C.db.profile.colors.cooldown[info[#info]]) + return E:GetRGB(C.db.global.colors.cooldown[info[#info]]) end, set = function(info, r,g, b) if r ~= nil then - local color = C.db.profile.colors.cooldown[info[#info]] + local color = C.db.global.colors.cooldown[info[#info]] if color.r ~= r or color.g ~= g or color.g ~= b then E:SetRGB(color, r, g, b) end @@ -1387,7 +1387,7 @@ function CONFIG:CreateGeneralPanel(order) name = L["RESTORE_DEFAULTS"], func = function() for k, v in next, D.profile.colors.cooldown do - E:SetRGB(C.db.profile.colors.cooldown[k], E:GetRGB(v)) + E:SetRGB(C.db.global.colors.cooldown[k], E:GetRGB(v)) end end, }, @@ -1428,11 +1428,11 @@ function CONFIG:CreateGeneralPanel(order) type = "group", name = L["ZONE"], get = function(info) - return E:GetRGB(C.db.profile.colors.zone[info[#info]]) + return E:GetRGB(C.db.global.colors.zone[info[#info]]) end, set = function(info, r, g, b) if r ~= nil then - local color = C.db.profile.colors.zone[info[#info]] + local color = C.db.global.colors.zone[info[#info]] if color.r ~= r or color.g ~= g or color.g ~= b then E:SetRGB(color, r, g, b) @@ -1450,7 +1450,7 @@ function CONFIG:CreateGeneralPanel(order) name = L["RESTORE_DEFAULTS"], func = function() for k, v in next, D.profile.colors.zone do - E:SetRGB(C.db.profile.colors.zone[k], E:GetRGB(v)) + E:SetRGB(C.db.global.colors.zone[k], E:GetRGB(v)) end if MINIMAP:IsInit() then diff --git a/core/cooldown.lua b/core/cooldown.lua index d2ce1951..5f60cecd 100644 --- a/core/cooldown.lua +++ b/core/cooldown.lua @@ -50,10 +50,10 @@ E.Cooldowns.Updater:SetScript("OnUpdate", function(_, elapsed) if remain >= 86400 then time1, time2, format = E:SecondsToTime(remain, "abbr") - color = C.db.profile.colors.cooldown.day + color = C.db.global.colors.cooldown.day elseif remain >= 3600 then time1, time2, format = E:SecondsToTime(remain, "abbr") - color = C.db.profile.colors.cooldown.hour + color = C.db.global.colors.cooldown.hour elseif remain >= 60 then if cooldown.config.m_ss_threshold == 0 or remain > cooldown.config.m_ss_threshold then time1, time2, format = E:SecondsToTime(remain, "abbr") @@ -61,7 +61,7 @@ E.Cooldowns.Updater:SetScript("OnUpdate", function(_, elapsed) time1, time2, format = E:SecondsToTime(remain, "x:xx") end - color = C.db.profile.colors.cooldown.minute + color = C.db.global.colors.cooldown.minute elseif remain >= 1 then if remain > cooldown.config.exp_threshold then time1, time2, format = E:SecondsToTime(remain, "abbr") @@ -69,14 +69,14 @@ E.Cooldowns.Updater:SetScript("OnUpdate", function(_, elapsed) time1, time2, format = E:SecondsToTime(remain, "frac") end - color = C.db.profile.colors.cooldown.second + color = C.db.global.colors.cooldown.second elseif remain >= 0.001 then time1, time2, format = E:SecondsToTime(remain) - color = C.db.profile.colors.cooldown.second + color = C.db.global.colors.cooldown.second end if remain <= cooldown.config.exp_threshold then - color = C.db.profile.colors.cooldown.expiration + color = C.db.global.colors.cooldown.expiration end if time1 then diff --git a/core/defaults.lua b/core/defaults.lua index 693d0992..0b58bdc6 100644 --- a/core/defaults.lua +++ b/core/defaults.lua @@ -61,13 +61,6 @@ D.global = { [2] = rgb(246, 196, 66), -- #F6C442 (2.5Y 8/10) [3] = rgb(46, 172, 52), -- #2EAC34 (10GY 6/12) }, - }, - tags = {}, - tag_vars = {}, -} - -D.profile = { - colors = { button = { normal = rgb(255, 255, 255), -- #FFFFFF unusable = rgb(107, 108, 107), -- #6B6C6B (N4) @@ -103,6 +96,7 @@ D.profile = { SOUL_SHARDS = rgb(149, 99, 202), -- #9563CA (2.5P 5/14) LUNAR_POWER = rgb(72, 152, 235), -- #4898EB (5PB 6/12) HOLY_POWER = rgb(238, 234, 140), -- #EEEA8C (10Y 9/6) + ALTERNATE = rgb(149, 134, 242), -- #9586F2 (10PB 6/14) MAELSTROM = rgb(38, 125, 206), -- #267DCE (5PB 5/12) INSANITY = rgb(125, 70, 174), -- #7D46AE (2.5P 4/14) CHI = rgb(108, 254, 214), -- #6CFED6 (10G 9/6) @@ -119,7 +113,6 @@ D.profile = { -- high [3] = rgb(211, 77, 81), -- #D34D51 (5R 5/12) }, - ALT_POWER = rgb(149, 134, 242), -- #9586F2 (10PB 6/14) }, reaction = { -- hated @@ -195,6 +188,9 @@ D.profile = { [3] = rgb(173, 235, 66), -- #ADEB42 (Blizzard Colour) }, }, +} + +D.profile = { units = { cooldown = { exp_threshold = 5, -- [1; 10] diff --git a/core/statusbar.lua b/core/statusbar.lua index 3b0de7f6..d00d0b59 100644 --- a/core/statusbar.lua +++ b/core/statusbar.lua @@ -553,8 +553,8 @@ do end local function updateColors(self) - self.Gain_:SetColorTexture(E:GetRGB(C.db.profile.colors.gain)) - self.Loss_:SetColorTexture(E:GetRGB(C.db.profile.colors.loss)) + self.Gain_:SetColorTexture(E:GetRGB(C.db.global.colors.gain)) + self.Loss_:SetColorTexture(E:GetRGB(C.db.global.colors.loss)) end local function updatePoints(self, orientation) diff --git a/core/utils.lua b/core/utils.lua index 3035d5d1..8b62dc81 100644 --- a/core/utils.lua +++ b/core/utils.lua @@ -324,16 +324,16 @@ end do function E:GetUnitColor(unit, colorByClass, colorByReaction) if not UnitIsConnected(unit) then - return C.db.profile.colors.disconnected + return C.db.global.colors.disconnected elseif not UnitPlayerControlled(unit) and UnitIsTapDenied(unit) then - return C.db.profile.colors.tapped + return C.db.global.colors.tapped elseif colorByClass and UnitIsPlayer(unit) then return self:GetUnitClassColor(unit) elseif colorByReaction then return self:GetUnitReactionColor(unit) end - return C.db.profile.colors.reaction[4] + return C.db.global.colors.reaction[4] end function E:GetUnitClassColor(unit) @@ -342,10 +342,10 @@ do function E:GetUnitReactionColor(unit) if select(2, UnitDetailedThreatSituation("player", unit)) ~= nil then - return C.db.profile.colors.reaction[2] + return C.db.global.colors.reaction[2] end - return C.db.profile.colors.reaction[UnitReaction(unit, "player")] or C.db.profile.colors.reaction[4] + return C.db.global.colors.reaction[UnitReaction(unit, "player")] or C.db.global.colors.reaction[4] end function E:GetUnitClassification(unit) @@ -414,15 +414,15 @@ do function E:GetRelativeDifficultyColor(unitLevel, challengeLevel) local diff = challengeLevel - unitLevel if diff >= 5 then - return C.db.profile.colors.difficulty.impossible + return C.db.global.colors.difficulty.impossible elseif diff >= 3 then - return C.db.profile.colors.difficulty.very_difficult + return C.db.global.colors.difficulty.very_difficult elseif diff >= -4 then - return C.db.profile.colors.difficulty.difficult + return C.db.global.colors.difficulty.difficult elseif -diff <= GetQuestGreenRange() then - return C.db.profile.colors.difficulty.standard + return C.db.global.colors.difficulty.standard else - return C.db.profile.colors.difficulty.trivial + return C.db.global.colors.difficulty.trivial end end diff --git a/init.lua b/init.lua index ad9f74eb..81071f5e 100644 --- a/init.lua +++ b/init.lua @@ -74,6 +74,15 @@ local function cleanUpStep1() C.db.profile.units.castbar = nil C.db.profile.units.colors = nil end + + -- -> 80100.07 + if not C.db.profile.version or C.db.profile.version < 8010007 then + if C.db.profile.colors then + E:CopyTable(C.db.profile.colors, C.db.global.colors) + + C.db.profile.colors = nil + end + end end local function cleanUpStep2() @@ -106,40 +115,42 @@ local function addRefs() C.db.profile.units.player = C.db.profile.units[E.UI_LAYOUT].player C.db.profile.units.pet = C.db.profile.units[E.UI_LAYOUT].pet - C.db.profile.colors.power[ 0] = C.db.profile.colors.power.MANA - C.db.profile.colors.power[ 1] = C.db.profile.colors.power.RAGE - C.db.profile.colors.power[ 2] = C.db.profile.colors.power.FOCUS - C.db.profile.colors.power[ 3] = C.db.profile.colors.power.ENERGY - C.db.profile.colors.power[ 4] = C.db.profile.colors.power.CHI - C.db.profile.colors.power[ 5] = C.db.profile.colors.power.RUNES - C.db.profile.colors.power[ 6] = C.db.profile.colors.power.RUNIC_POWER - C.db.profile.colors.power[ 7] = C.db.profile.colors.power.SOUL_SHARDS - C.db.profile.colors.power[ 8] = C.db.profile.colors.power.LUNAR_POWER - C.db.profile.colors.power[ 9] = C.db.profile.colors.power.HOLY_POWER - C.db.profile.colors.power[11] = C.db.profile.colors.power.MAELSTROM - C.db.profile.colors.power[13] = C.db.profile.colors.power.INSANITY - C.db.profile.colors.power[17] = C.db.profile.colors.power.FURY - C.db.profile.colors.power[18] = C.db.profile.colors.power.PAIN + C.db.global.colors.power[ 0] = C.db.global.colors.power.MANA + C.db.global.colors.power[ 1] = C.db.global.colors.power.RAGE + C.db.global.colors.power[ 2] = C.db.global.colors.power.FOCUS + C.db.global.colors.power[ 3] = C.db.global.colors.power.ENERGY + C.db.global.colors.power[ 4] = C.db.global.colors.power.CHI + C.db.global.colors.power[ 5] = C.db.global.colors.power.RUNES + C.db.global.colors.power[ 6] = C.db.global.colors.power.RUNIC_POWER + C.db.global.colors.power[ 7] = C.db.global.colors.power.SOUL_SHARDS + C.db.global.colors.power[ 8] = C.db.global.colors.power.LUNAR_POWER + C.db.global.colors.power[ 9] = C.db.global.colors.power.HOLY_POWER + C.db.global.colors.power[10] = C.db.global.colors.power.ALTERNATE + C.db.global.colors.power[11] = C.db.global.colors.power.MAELSTROM + C.db.global.colors.power[13] = C.db.global.colors.power.INSANITY + C.db.global.colors.power[17] = C.db.global.colors.power.FURY + C.db.global.colors.power[18] = C.db.global.colors.power.PAIN end local function removeRefs() C.db.profile.units.player = nil C.db.profile.units.pet = nil - C.db.profile.colors.power[ 0] = nil - C.db.profile.colors.power[ 1] = nil - C.db.profile.colors.power[ 2] = nil - C.db.profile.colors.power[ 3] = nil - C.db.profile.colors.power[ 4] = nil - C.db.profile.colors.power[ 5] = nil - C.db.profile.colors.power[ 6] = nil - C.db.profile.colors.power[ 7] = nil - C.db.profile.colors.power[ 8] = nil - C.db.profile.colors.power[ 9] = nil - C.db.profile.colors.power[11] = nil - C.db.profile.colors.power[13] = nil - C.db.profile.colors.power[17] = nil - C.db.profile.colors.power[18] = nil + C.db.global.colors.power[ 0] = nil + C.db.global.colors.power[ 1] = nil + C.db.global.colors.power[ 2] = nil + C.db.global.colors.power[ 3] = nil + C.db.global.colors.power[ 4] = nil + C.db.global.colors.power[ 5] = nil + C.db.global.colors.power[ 6] = nil + C.db.global.colors.power[ 7] = nil + C.db.global.colors.power[ 8] = nil + C.db.global.colors.power[ 9] = nil + C.db.global.colors.power[10] = nil + C.db.global.colors.power[11] = nil + C.db.global.colors.power[13] = nil + C.db.global.colors.power[17] = nil + C.db.global.colors.power[18] = nil end local function updateAll() diff --git a/modules/auras/auras.lua b/modules/auras/auras.lua index 469c970a..f05c7a8a 100644 --- a/modules/auras/auras.lua +++ b/modules/auras/auras.lua @@ -61,7 +61,7 @@ local function updateAura(button, index) end if filter == "HARMFUL" then - button.Border:SetVertexColor(E:GetRGB(C.db.profile.colors.debuff[debuffType] or C.db.profile.colors.debuff.None)) + button.Border:SetVertexColor(E:GetRGB(C.db.global.colors.debuff[debuffType] or C.db.global.colors.debuff.None)) if debuffType and debuffType ~= "" and button.showDebuffType then button.AuraType:SetTexCoord(unpack(ICONS[debuffType])) @@ -101,7 +101,7 @@ local function updateTempEnchant(button, index) button.Cooldown:Hide() end - button.Border:SetVertexColor(E:GetRGB(C.db.profile.colors.buff.Enchant)) + button.Border:SetVertexColor(E:GetRGB(C.db.global.colors.buff.Enchant)) end end diff --git a/modules/auratracker/auratracker.lua b/modules/auratracker/auratracker.lua index f198cc10..ce8833db 100644 --- a/modules/auratracker/auratracker.lua +++ b/modules/auratracker/auratracker.lua @@ -114,7 +114,7 @@ local function bar_OnEvent(self) end if button.filter == "HARMFUL" then - button.Border:SetVertexColor(E:GetRGB(C.db.profile.colors.debuff[aura.debuffType] or C.db.profile.colors.debuff.None)) + button.Border:SetVertexColor(E:GetRGB(C.db.global.colors.debuff[aura.debuffType] or C.db.global.colors.debuff.None)) button.AuraType:SetTexture("Interface\\PETBATTLES\\BattleBar-AbilityBadge-Weak") else button.Border:SetVertexColor(1, 1, 1) diff --git a/modules/bars/actionbars.lua b/modules/bars/actionbars.lua index 0914408c..ea558021 100644 --- a/modules/bars/actionbars.lua +++ b/modules/bars/actionbars.lua @@ -169,7 +169,7 @@ local function bar_UpdateButtonConfig(self) } end - for k, v in next, C.db.profile.colors.button do + for k, v in next, C.db.global.colors.button do self.buttonConfig.colors[k][1], self.buttonConfig.colors[k][2], self.buttonConfig.colors[k][3] = E:GetRGB(v) end diff --git a/modules/bars/petbar.lua b/modules/bars/petbar.lua index 3b23b70d..2a960cee 100644 --- a/modules/bars/petbar.lua +++ b/modules/bars/petbar.lua @@ -83,7 +83,7 @@ local function bar_UpdateButtonConfig(self) } end - for k, v in next, C.db.profile.colors.button do + for k, v in next, C.db.global.colors.button do self.buttonConfig.colors[k][1], self.buttonConfig.colors[k][2], self.buttonConfig.colors[k][3] = E:GetRGB(v) end diff --git a/modules/bars/stancebar.lua b/modules/bars/stancebar.lua index f04060a4..83ced0af 100644 --- a/modules/bars/stancebar.lua +++ b/modules/bars/stancebar.lua @@ -72,13 +72,13 @@ local function button_Update(self) if isCastable then self.icon:SetDesaturated(false) - self.icon:SetVertexColor(E:GetRGB(C.db.profile.colors.button.normal)) + self.icon:SetVertexColor(E:GetRGB(C.db.global.colors.button.normal)) else self.icon:SetDesaturated(true) - self.icon:SetVertexColor(E:GetRGB(C.db.profile.colors.button.unusable)) + self.icon:SetVertexColor(E:GetRGB(C.db.global.colors.button.unusable)) end - self.HotKey:SetVertexColor(E:GetRGB(C.db.profile.colors.button.normal)) + self.HotKey:SetVertexColor(E:GetRGB(C.db.global.colors.button.normal)) self:UpdateHotKey() self:UpdateCooldown() diff --git a/modules/bars/xpbar.lua b/modules/bars/xpbar.lua index 43d8ed68..b58497bb 100644 --- a/modules/bars/xpbar.lua +++ b/modules/bars/xpbar.lua @@ -150,7 +150,7 @@ local function bar_UpdateSegments(self) line1 = L["LEVEL_TOOLTIP"]:format(level), } - self[index]:Update(cur, max, 0, C.db.profile.colors.xp[2]) + self[index]:Update(cur, max, 0, C.db.global.colors.xp[2]) end else -- Artefact @@ -166,7 +166,7 @@ local function bar_UpdateSegments(self) line2 = L["ARTIFACT_LEVEL_TOOLTIP"]:format(pointsSpent), } - self[index]:Update(cur, max, 0, C.db.profile.colors.artifact) + self[index]:Update(cur, max, 0, C.db.global.colors.artifact) end -- Azerite @@ -205,7 +205,7 @@ local function bar_UpdateSegments(self) self[index].tooltipInfo.line2 = nil end - self[index]:Update(cur, max, bonus, bonus > 0 and C.db.profile.colors.xp[1] or C.db.profile.colors.xp[2]) + self[index]:Update(cur, max, bonus, bonus > 0 and C.db.global.colors.xp[1] or C.db.global.colors.xp[2]) end -- Honour @@ -219,7 +219,7 @@ local function bar_UpdateSegments(self) line1 = L["HONOR_LEVEL_TOOLTIP"]:format(UnitHonorLevel("player")), } - self[index]:Update(cur, max, 0, C.db.profile.colors.faction[UnitFactionGroup("player")]) + self[index]:Update(cur, max, 0, C.db.global.colors.faction[UnitFactionGroup("player")]) end -- Reputation @@ -263,7 +263,7 @@ local function bar_UpdateSegments(self) self[index].tooltipInfo = { header = L["REPUTATION"], - line1 = REPUTATION_TEMPLATE:format(name, C.db.profile.colors.reaction[standing].hex, repTextLevel), + line1 = REPUTATION_TEMPLATE:format(name, C.db.global.colors.reaction[standing].hex, repTextLevel), } if isParagon and hasRewardPending then @@ -276,7 +276,7 @@ local function bar_UpdateSegments(self) self[index].tooltipInfo.line3 = nil end - self[index]:Update(cur, max, 0, C.db.profile.colors.reaction[standing]) + self[index]:Update(cur, max, 0, C.db.global.colors.reaction[standing]) end end diff --git a/modules/blizzard/castbar.lua b/modules/blizzard/castbar.lua index 8fbc066a..32a55667 100644 --- a/modules/blizzard/castbar.lua +++ b/modules/blizzard/castbar.lua @@ -187,11 +187,11 @@ local function updateFontObject(fontString, config) end local function updateColors(self) - CastingBarFrame_SetStartCastColor(self, E:GetRGB(C.db.profile.colors.castbar.casting)) - CastingBarFrame_SetStartChannelColor(self, E:GetRGB(C.db.profile.colors.castbar.channeling)) - CastingBarFrame_SetFinishedCastColor(self, E:GetRGB(C.db.profile.colors.castbar.casting)) - CastingBarFrame_SetNonInterruptibleCastColor(self, E:GetRGB(C.db.profile.colors.castbar.notinterruptible)) - CastingBarFrame_SetFailedCastColor(self, E:GetRGB(C.db.profile.colors.castbar.failed)) + CastingBarFrame_SetStartCastColor(self, E:GetRGB(C.db.global.colors.castbar.casting)) + CastingBarFrame_SetStartChannelColor(self, E:GetRGB(C.db.global.colors.castbar.channeling)) + CastingBarFrame_SetFinishedCastColor(self, E:GetRGB(C.db.global.colors.castbar.casting)) + CastingBarFrame_SetNonInterruptibleCastColor(self, E:GetRGB(C.db.global.colors.castbar.notinterruptible)) + CastingBarFrame_SetFailedCastColor(self, E:GetRGB(C.db.global.colors.castbar.failed)) CastingBarFrame_SetUseStartColorForFinished(self, true) end diff --git a/modules/minimap/minimap.lua b/modules/minimap/minimap.lua index 7042cf8f..12fcb276 100644 --- a/modules/minimap/minimap.lua +++ b/modules/minimap/minimap.lua @@ -365,7 +365,7 @@ end local function minimap_UpdateBorderColor(self) if self._config.color.border then - self.Border:SetVertexColor(E:GetRGB(C.db.profile.colors.zone[PVP_COLOR_MAP[GetZonePVPInfo()]] or C.db.profile.colors.zone.contested)) + self.Border:SetVertexColor(E:GetRGB(C.db.global.colors.zone[PVP_COLOR_MAP[GetZonePVPInfo()]] or C.db.global.colors.zone.contested)) else self.Border:SetVertexColor(1, 1, 1) end @@ -419,7 +419,7 @@ end local function minimap_UpdateZoneColor(self) if self._config.color.zone_text then - self.Zone.Text:SetVertexColor(E:GetRGB(C.db.profile.colors.zone[PVP_COLOR_MAP[GetZonePVPInfo()]] or C.db.profile.colors.zone.contested)) + self.Zone.Text:SetVertexColor(E:GetRGB(C.db.global.colors.zone[PVP_COLOR_MAP[GetZonePVPInfo()]] or C.db.global.colors.zone.contested)) else self.Zone.Text:SetVertexColor(1, 1, 1) end diff --git a/modules/tooltips/tooltips.lua b/modules/tooltips/tooltips.lua index b753d7c7..f15f99a9 100644 --- a/modules/tooltips/tooltips.lua +++ b/modules/tooltips/tooltips.lua @@ -700,7 +700,7 @@ local function tooltipBar_Hook(self) self:GetParent():SetMinimumWidth(self.Text:GetStringWidth() + 32) end - self:SetStatusBarColor(E:GetRGB(C.db.profile.colors.health)) + self:SetStatusBarColor(E:GetRGB(C.db.global.colors.health)) end function MODULE.IsInit() diff --git a/modules/unitframes/core.lua b/modules/unitframes/core.lua index 61b82173..6af97dbc 100644 --- a/modules/unitframes/core.lua +++ b/modules/unitframes/core.lua @@ -112,25 +112,25 @@ end function UF:UpdateHealthColors() local color = oUF.colors.health - color[1], color[2], color[3] = E:GetRGB(C.db.profile.colors.health) + color[1], color[2], color[3] = E:GetRGB(C.db.global.colors.health) color = oUF.colors.tapped - color[1], color[2], color[3] = E:GetRGB(C.db.profile.colors.tapped) + color[1], color[2], color[3] = E:GetRGB(C.db.global.colors.tapped) color = oUF.colors.disconnected - color[1], color[2], color[3] = E:GetRGB(C.db.profile.colors.disconnected) + color[1], color[2], color[3] = E:GetRGB(C.db.global.colors.disconnected) end function UF:UpdateReactionColors() local color = oUF.colors.reaction - for k, v in next, C.db.profile.colors.reaction do + for k, v in next, C.db.global.colors.reaction do color[k][1], color[k][2], color[k][3] = E:GetRGB(v) end end function UF:UpdatePowerColors() local color = oUF.colors.power - for k, myColor in next, C.db.profile.colors.power do + for k, myColor in next, C.db.global.colors.power do if type(k) == "string" then if not color[k] then color[k] = {} @@ -147,7 +147,7 @@ function UF:UpdatePowerColors() end color = oUF.colors.runes - for k, v in next, C.db.profile.colors.rune do + for k, v in next, C.db.global.colors.rune do color[k][1], color[k][2], color[k][3] = E:GetRGB(v) end end diff --git a/modules/unitframes/elements/auras.lua b/modules/unitframes/elements/auras.lua index 5c4cb327..1b3e09f8 100644 --- a/modules/unitframes/elements/auras.lua +++ b/modules/unitframes/elements/auras.lua @@ -317,7 +317,7 @@ end local function element_PostUpdateIcon(self, _, aura, _, _, _, _, debuffType) if aura.isDebuff then - aura.Border:SetVertexColor(E:GetRGB(C.db.profile.colors.debuff[debuffType] or C.db.profile.colors.debuff.None)) + aura.Border:SetVertexColor(E:GetRGB(C.db.global.colors.debuff[debuffType] or C.db.global.colors.debuff.None)) if self._config.type.debuff_type then aura.AuraType:SetTexCoord(unpack(ICONS[debuffType] or ICONS["Debuff"])) diff --git a/modules/unitframes/elements/castbar.lua b/modules/unitframes/elements/castbar.lua index 12f0174d..b51d4e84 100644 --- a/modules/unitframes/elements/castbar.lua +++ b/modules/unitframes/elements/castbar.lua @@ -24,16 +24,16 @@ end local function element_PostCastStart(self) if self.notInterruptible then - self:SetStatusBarColor(E:GetRGB(C.db.profile.colors.castbar.notinterruptible)) + self:SetStatusBarColor(E:GetRGB(C.db.global.colors.castbar.notinterruptible)) if self.Icon then self.Icon:SetDesaturated(true) end else if self.casting then - self:SetStatusBarColor(E:GetRGB(C.db.profile.colors.castbar.casting)) + self:SetStatusBarColor(E:GetRGB(C.db.global.colors.castbar.casting)) elseif self.channeling then - self:SetStatusBarColor(E:GetRGB(C.db.profile.colors.castbar.channeling)) + self:SetStatusBarColor(E:GetRGB(C.db.global.colors.castbar.channeling)) end if self.Icon then @@ -45,7 +45,7 @@ end local function element_PostCastFail(self) self:SetMinMaxValues(0, 1) self:SetValue(1) - self:SetStatusBarColor(E:GetRGB(C.db.profile.colors.castbar.failed)) + self:SetStatusBarColor(E:GetRGB(C.db.global.colors.castbar.failed)) self.Time:SetText("") end diff --git a/modules/unitframes/elements/classindicator.lua b/modules/unitframes/elements/classindicator.lua index 0a7b1be4..76c4825a 100644 --- a/modules/unitframes/elements/classindicator.lua +++ b/modules/unitframes/elements/classindicator.lua @@ -23,7 +23,7 @@ local function update(self) color = C.db.global.colors.class[class] elseif element._config.color.reaction and UnitReaction(self.unit, "player") then local reaction = UnitReaction(self.unit, "player") - color = C.db.profile.colors.reaction[reaction] + color = C.db.global.colors.reaction[reaction] else local class = UnitClassification(self.unit) if class and (class == "worldboss" or class == "elite" or class == "rareelite") then diff --git a/modules/unitframes/elements/classpower.lua b/modules/unitframes/elements/classpower.lua index af3e7cbf..b03e197c 100644 --- a/modules/unitframes/elements/classpower.lua +++ b/modules/unitframes/elements/classpower.lua @@ -218,7 +218,7 @@ do self[i]:SetHeight(layout[i]) end - self[i]:SetStatusBarColor(E:GetRGB(C.db.profile.colors.power[powerType])) + self[i]:SetStatusBarColor(E:GetRGB(C.db.global.colors.power[powerType])) end end @@ -235,7 +235,7 @@ do local function element_UpdateColors(self) if self._powerID then for i = 1, 10 do - self[i]:SetStatusBarColor(E:GetRGB(C.db.profile.colors.power[self._powerID])) + self[i]:SetStatusBarColor(E:GetRGB(C.db.global.colors.power[self._powerID])) end end end @@ -336,7 +336,7 @@ do if unit and unit ~= self.unit then return end local element = self.Stagger - element:SetStatusBarColor(E:GetGradientAsRGB((element.cur or 0) / (element.max or 1), C.db.profile.colors.power.STAGGER)) + element:SetStatusBarColor(E:GetGradientAsRGB((element.cur or 0) / (element.max or 1), C.db.global.colors.power.STAGGER)) end local function element_UpdateConfig(self) diff --git a/modules/unitframes/elements/health.lua b/modules/unitframes/elements/health.lua index c9eafe4a..70bcb9c7 100644 --- a/modules/unitframes/elements/health.lua +++ b/modules/unitframes/elements/health.lua @@ -177,9 +177,9 @@ do end local function element_UpdateColors(self) - self.myBar._texture:SetColorTexture(E:GetRGBA(C.db.profile.colors.prediction.my_heal)) - self.otherBar._texture:SetColorTexture(E:GetRGBA(C.db.profile.colors.prediction.other_heal)) - self.healAbsorbBar._texture:SetColorTexture(E:GetRGBA(C.db.profile.colors.prediction.heal_absorb)) + self.myBar._texture:SetColorTexture(E:GetRGBA(C.db.global.colors.prediction.my_heal)) + self.otherBar._texture:SetColorTexture(E:GetRGBA(C.db.global.colors.prediction.other_heal)) + self.healAbsorbBar._texture:SetColorTexture(E:GetRGBA(C.db.global.colors.prediction.heal_absorb)) end local function frame_UpdateHealthPrediction(self) diff --git a/modules/unitframes/elements/power.lua b/modules/unitframes/elements/power.lua index 97b32657..060f4f24 100644 --- a/modules/unitframes/elements/power.lua +++ b/modules/unitframes/elements/power.lua @@ -255,7 +255,7 @@ do end local function element_UpdateColors(self) - self:SetStatusBarColor(E:GetRGB(C.db.profile.colors.power.ALT_POWER)) + self:SetStatusBarColor(E:GetRGB(C.db.global.colors.power.ALTERNATE)) end local function frame_UpdateAlternativePower(self) @@ -326,8 +326,8 @@ do end local function element_UpdateColors(self) - self.mainBar_:SetStatusBarColor(E:GetRGB(C.db.profile.colors.prediction.power_cost)) - self.altBar_:SetStatusBarColor(E:GetRGB(C.db.profile.colors.prediction.power_cost)) + self.mainBar_:SetStatusBarColor(E:GetRGB(C.db.global.colors.prediction.power_cost)) + self.altBar_:SetStatusBarColor(E:GetRGB(C.db.global.colors.prediction.power_cost)) end local function frame_UpdatePowerPrediction(frame) diff --git a/modules/unitframes/elements/tags.lua b/modules/unitframes/elements/tags.lua index f943b5e9..ccde4446 100644 --- a/modules/unitframes/elements/tags.lua +++ b/modules/unitframes/elements/tags.lua @@ -97,7 +97,7 @@ oUF.Tags.Events["ls:color:reaction"] = "UNIT_FACTION UNIT_NAME_UPDATE" oUF.Tags.Methods["ls:color:reaction"] = function(unit) local reaction = UnitReaction(unit, 'player') if reaction then - return "|c" .. C.db.profile.colors.reaction[reaction].hex + return "|c" .. C.db.global.colors.reaction[reaction].hex end return "|cffffffff" @@ -111,7 +111,7 @@ end oUF.Tags.Methods["ls:color:power"] = function(unit) local type, _, r, g, b = UnitPowerType(unit) if not r then - return "|c" .. C.db.profile.colors.power[type].hex + return "|c" .. C.db.global.colors.power[type].hex else if r > 1 or g > 1 or b > 1 then r, g, b = r / 255, g / 255, b / 255 @@ -122,15 +122,15 @@ oUF.Tags.Methods["ls:color:power"] = function(unit) end oUF.Tags.Methods["ls:color:altpower"] = function() - return "|c" .. C.db.profile.colors.power.ALT_POWER.hex + return "|c" .. C.db.global.colors.power.ALTERNATE.hex end oUF.Tags.Methods["ls:color:absorb-damage"] = function() - return "|c" .. C.db.profile.colors.prediction.damage_absorb.hex + return "|c" .. C.db.global.colors.prediction.damage_absorb.hex end oUF.Tags.Methods["ls:color:absorb-heal"] = function() - return "|c" .. C.db.profile.colors.prediction.heal_absorb.hex + return "|c" .. C.db.global.colors.prediction.heal_absorb.hex end ------------ From 6f5a0ee621587211a87078c1e687ebe38aaefcc0 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Tue, 7 May 2019 16:38:34 +0700 Subject: [PATCH 08/20] Fix a typo --- config/general.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/general.lua b/config/general.lua index 729c2f0b..11499ff4 100644 --- a/config/general.lua +++ b/config/general.lua @@ -292,7 +292,7 @@ end local updateTagVarsOptions do local function isDefaultTag(info) - return D.global.tags[info[#info - 1]] + return D.global.tag_vars[info[#info - 1]] end local function validateTagVars(_, value) From d938250c7b15d6caf47a198f76b6b212b229785c Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Tue, 7 May 2019 16:39:07 +0700 Subject: [PATCH 09/20] Make config panel bigger --- config/core.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/core.lua b/config/core.lua index 7dae9891..2734e5d6 100644 --- a/config/core.lua +++ b/config/core.lua @@ -719,7 +719,7 @@ function MODULE.Init() } AceConfig:RegisterOptionsTable(addonName, C.options) - AceConfigDialog:SetDefaultSize(addonName, 1024, 768) + AceConfigDialog:SetDefaultSize(addonName, 1228, 768) MODULE:CreateGeneralPanel(5) MODULE:CreateActionBarsPanel(6) From 0f9ee1e9b39eac6ab98620796773f7c60896bf63 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Tue, 7 May 2019 16:39:25 +0700 Subject: [PATCH 10/20] =?UTF-8?q?=F0=9F=92=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/core.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/config/core.lua b/config/core.lua index 2734e5d6..5ae5e4ca 100644 --- a/config/core.lua +++ b/config/core.lua @@ -573,9 +573,8 @@ do end end -function MODULE.SetStatusText(_, text) +function MODULE:SetStatusText(text) local frame = AceConfigDialog.OpenFrames[addonName] - if frame then frame:SetStatusText(text) end @@ -584,7 +583,6 @@ end -- MODULE.IsTagStringValid do local badTags = {} - local badTag = "|cffffffff%s|r" local function getTagName(tag) local tagStart = (tag:match('>+()') or 2) @@ -599,7 +597,7 @@ do for bracket in tagString:gmatch("%[..-%]+") do if not oUF.Tags.Methods[getTagName(bracket)] then - t_insert(badTags, badTag:format(bracket)) + t_insert(badTags, "|cffffffff" .. bracket .. "|r") end end From 5bf2660b0e11f3da2c5a26bd4ae1ca1b86a54691 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Tue, 7 May 2019 17:38:47 +0700 Subject: [PATCH 11/20] Allow nils for tag vars and events --- config/general.lua | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/config/general.lua b/config/general.lua index 11499ff4..c50a223d 100644 --- a/config/general.lua +++ b/config/general.lua @@ -96,10 +96,14 @@ do validate = validateTagEvents, set = function(info, value) value = s_trim(value) - if value ~= "" and C.db.global.tags[info[#info - 1]].events ~= value then - C.db.global.tags[info[#info - 1]].events = value - - oUF.Tags.Events[info[#info - 1]] = value + if C.db.global.tags[info[#info - 1]].events ~= value then + if value ~= "" then + C.db.global.tags[info[#info - 1]].events = value + oUF.Tags.Events[info[#info - 1]] = value + else + C.db.global.tags[info[#info - 1]].events = nil + oUF.Tags.Events[info[#info - 1]] = nil + end oUF.Tags:RefreshEvents(info[#info - 1]) end @@ -115,11 +119,15 @@ do validate = validateTagVars, set = function(info, value) value = tonumber(value) or s_trim(value) - if value ~= "" and C.db.global.tags[info[#info - 1]].vars ~= value then - C.db.global.tags[info[#info - 1]].vars = value - + if C.db.global.tags[info[#info - 1]].vars ~= value then rawset(oUF.Tags.Vars, info[#info - 1], nil) - oUF.Tags.Vars[info[#info - 1]] = value + + if value ~= "" then + C.db.global.tags[info[#info - 1]].vars = value + oUF.Tags.Vars[info[#info - 1]] = value + else + C.db.global.tags[info[#info - 1]].vars = nil + end end end, }, @@ -346,11 +354,15 @@ do end, set = function(info, value) value = tonumber(value) or s_trim(value) - if value ~= "" and C.db.global.tag_vars[info[#info - 1]] ~= value then - C.db.global.tag_vars[info[#info - 1]] = value - + if C.db.global.tag_vars[info[#info - 1]] ~= value then rawset(oUF.Tags.Vars, info[#info - 1], nil) - oUF.Tags.Vars[info[#info - 1]] = value + + if value ~= "" then + C.db.global.tag_vars[info[#info - 1]] = value + oUF.Tags.Vars[info[#info - 1]] = value + else + C.db.global.tag_vars[info[#info - 1]] = nil + end end end, }, From fc6312569c578da41d69f289ad5438de8f85e003 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Tue, 7 May 2019 18:12:10 +0700 Subject: [PATCH 12/20] Add | handling --- config/general.lua | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/config/general.lua b/config/general.lua index c50a223d..bf0cccd8 100644 --- a/config/general.lua +++ b/config/general.lua @@ -57,7 +57,7 @@ do name = L["NAME"], disabled = isDefaultTag, validate = function(info, value) - value = s_trim(value) + value = s_trim(value):gsub("\124\124+", "\124") CONFIG:SetStatusText("") return (value ~= info[#info - 1] and oUF.Tags.Methods[value]) and L["NAME_TAKEN_ERR"] or true @@ -66,7 +66,7 @@ do return info[#info - 1] end, set = function(info, value) - value = s_trim(value) + value = s_trim(value):gsub("\124\124+", "\124") if value ~= "" and value ~= info[#info - 1] then if not C.db.global.tags[value] then C.db.global.tags[value] = C.db.global.tags[info[#info - 1]] @@ -95,7 +95,7 @@ do name = L["EVENTS"], validate = validateTagEvents, set = function(info, value) - value = s_trim(value) + value = s_trim(value):gsub("\124\124+", "\124") if C.db.global.tags[info[#info - 1]].events ~= value then if value ~= "" then C.db.global.tags[info[#info - 1]].events = value @@ -118,7 +118,7 @@ do disabled = isDefaultTag, validate = validateTagVars, set = function(info, value) - value = tonumber(value) or s_trim(value) + value = tonumber(value) or s_trim(value):gsub("\124\124+", "\124") if C.db.global.tags[info[#info - 1]].vars ~= value then rawset(oUF.Tags.Vars, info[#info - 1], nil) @@ -139,7 +139,7 @@ do multiline = 16, validate = validateTagFunc, set = function(info, value) - value = s_trim(value) + value = s_trim(value):gsub("\124\124+", "\124") if C.db.global.tags[info[#info - 1]].func ~= value then C.db.global.tags[info[#info - 1]].func = value @@ -182,10 +182,10 @@ do type = "group", name = L["NEW_TAG"], get = function(info) - return tostring(newTagInfo[info[#info]]) + return tostring(newTagInfo[info[#info]]):gsub("\124", "\124\124") end, set = function(info, value) - newTagInfo[info[#info]] = s_trim(value) + newTagInfo[info[#info]] = s_trim(value):gsub("\124\124+", "\124") end, args = { name = { @@ -194,7 +194,7 @@ do width = "full", name = L["NAME"], validate = function(_, value) - value = s_trim(value) + value = s_trim(value):gsub("\124\124+", "\124") CONFIG:SetStatusText("") return oUF.Tags.Methods[value] and L["NAME_TAKEN_ERR"] or true @@ -215,7 +215,7 @@ do multiline = 8, validate = validateTagVars, set = function(_, value) - newTagInfo.vars = tonumber(value) or s_trim(value) + newTagInfo.vars = tonumber(value) or s_trim(value):gsub("\124\124+", "\124") end, }, func = { @@ -316,7 +316,7 @@ do name = L["NAME"], disabled = isDefaultTag, validate = function(info, value) - value = s_trim(value) + value = s_trim(value):gsub("\124\124+", "\124") CONFIG:SetStatusText("") return (value ~= info[#info - 1] and oUF.Tags.Vars[value]) and L["NAME_TAKEN_ERR"] or true @@ -325,7 +325,7 @@ do return info[#info - 1] end, set = function(info, value) - value = s_trim(value) + value = s_trim(value):gsub("\124\124+", "\124") if value ~= "" and value ~= info[#info - 1] then if not C.db.global.tag_vars[value] then C.db.global.tag_vars[value] = C.db.global.tag_vars[info[#info - 1]] @@ -350,10 +350,10 @@ do disabled = isDefaultTag, validate = validateTagVars, get = function(info) - return tostring(C.db.global.tag_vars[info[#info - 1]]) + return tostring(C.db.global.tag_vars[info[#info - 1]]):gsub("\124", "\124\124") end, set = function(info, value) - value = tonumber(value) or s_trim(value) + value = tonumber(value) or s_trim(value):gsub("\124\124+", "\124") if C.db.global.tag_vars[info[#info - 1]] ~= value then rawset(oUF.Tags.Vars, info[#info - 1], nil) @@ -394,7 +394,7 @@ do type = "group", name = L["NEW_VAR"], get = function(info) - return tostring(newVarInfo[info[#info]]) + return tostring(newVarInfo[info[#info]]):gsub("\124", "\124\124") end, args = { name = { @@ -403,13 +403,13 @@ do width = "full", name = L["NAME"], validate = function(_, value) - value = s_trim(value) + value = s_trim(value):gsub("\124\124+", "\124") CONFIG:SetStatusText("") return oUF.Tags.Vars[value] and L["NAME_TAKEN_ERR"] or true end, set = function(_, value) - newVarInfo.name = s_trim(value) + newVarInfo.name = s_trim(value):gsub("\124\124+", "\124") end, }, value = { @@ -420,7 +420,7 @@ do multiline = 16, validate = validateTagVars, set = function(_, value) - newVarInfo.value = tonumber(value) or s_trim(value) + newVarInfo.value = tonumber(value) or s_trim(value):gsub("\124\124+", "\124") end, }, add = { @@ -1506,7 +1506,7 @@ function CONFIG:CreateGeneralPanel(order) childGroups = "tree", name = L["TAGS"], get = function(info) - return tostring(C.db.global.tags[info[#info - 1]][info[#info]] or "") + return tostring(C.db.global.tags[info[#info - 1]][info[#info]] or ""):gsub("\124", "\124\124") end, args = {}, }, From c4e19f9d36fbdd43ce1ff5314cbad49c838599d8 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Tue, 7 May 2019 18:40:22 +0700 Subject: [PATCH 13/20] Take ALT_POWER to ALTERNATE rename into account --- init.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/init.lua b/init.lua index 81071f5e..4eabf7d7 100644 --- a/init.lua +++ b/init.lua @@ -78,6 +78,11 @@ local function cleanUpStep1() -- -> 80100.07 if not C.db.profile.version or C.db.profile.version < 8010007 then if C.db.profile.colors then + if C.db.profile.colors.power and C.db.profiles.colors.power.ALT_POWER then + C.db.profiles.colors.power.ALTERNATE = C.db.profiles.colors.power.ALT_POWER + C.db.profiles.colors.power.ALT_POWER = nil + end + E:CopyTable(C.db.profile.colors, C.db.global.colors) C.db.profile.colors = nil From 928af5ebb07f860e5002dfc33de24f7fdfb44daa Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Thu, 9 May 2019 13:43:08 +0700 Subject: [PATCH 14/20] Add the "Restore Defaults" button for the default tags --- config/general.lua | 27 ++++++++++++++++++++++++++- core/core.lua | 16 ++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/config/general.lua b/config/general.lua index bf0cccd8..e5bd66c8 100644 --- a/config/general.lua +++ b/config/general.lua @@ -155,7 +155,7 @@ do type = "execute", name = L["DELETE"], width = "full", - disabled = isDefaultTag, + hidden = isDefaultTag, func = function(info) C.db.global.tags[info[#info - 1]] = nil oUF.Tags.Events[info[#info - 1]] = nil @@ -167,6 +167,31 @@ do AceConfigDialog:SelectGroup("ls_UI", "general", "tags") end, }, + reset = { + type = "execute", + order = 6, + name = L["RESTORE_DEFAULTS"], + width = "full", + hidden = function(info) + return not D.global.tags[info[#info - 1]] + end, + func = function(info) + local tag = info[#info - 1] + + E:ReplaceTable(D.global.tags[tag], C.db.global.tags[tag]) + + oUF.Tags.Events[tag] = nil + rawset(oUF.Tags.Methods, tag, nil) + + if C.db.global.tags[tag].events then + oUF.Tags.Events[tag] = C.db.global.tags[tag].events + oUF.Tags:RefreshEvents(tag) + end + + oUF.Tags.Methods[tag] = C.db.global.tags[tag].func + oUF.Tags:RefreshMethods(tag) + end, + }, } local newTagInfo = { diff --git a/core/core.lua b/core/core.lua index c5e00673..19c51c2e 100644 --- a/core/core.lua +++ b/core/core.lua @@ -203,6 +203,22 @@ function E:UpdateTable(src, dest) return dest end +function E:ReplaceTable(src, dest) + if type(dest) ~= "table" then + dest = {} + end + + for k, v in next, dest do + if type(src[k]) == "table" then + dest[k] = self:ReplaceTable(src[k], v) + else + dest[k] = src[k] + end + end + + return dest +end + function E:DiffTable(src , dest) if type(dest) ~= "table" then return {} From 04bff0115b329af2dd74b50a2d2288d5aa475176 Mon Sep 17 00:00:00 2001 From: Val Voronov Date: Thu, 9 May 2019 14:00:03 +0700 Subject: [PATCH 15/20] Move tags to defaults.lua This will make them editable --- core/defaults.lua | 184 +++++++ modules/unitframes/core.lua | 3 + modules/unitframes/elements/_elements.xml | 1 - modules/unitframes/elements/tags.lua | 606 ---------------------- 4 files changed, 187 insertions(+), 607 deletions(-) delete mode 100644 modules/unitframes/elements/tags.lua diff --git a/core/defaults.lua b/core/defaults.lua index 0b58bdc6..c860f8e7 100644 --- a/core/defaults.lua +++ b/core/defaults.lua @@ -188,6 +188,190 @@ D.global = { [3] = rgb(173, 235, 66), -- #ADEB42 (Blizzard Colour) }, }, + tags = { + ["ls:absorb:damage"] = { + events = "UNIT_ABSORB_AMOUNT_CHANGED", + func = "function(unit)\n local absorb = UnitGetTotalAbsorbs(unit) or 0\n return absorb > 0 and _VARS.E:FormatNumber(absorb) or \" \"\nend", + }, + ["ls:absorb:heal"] = { + events = "UNIT_HEAL_ABSORB_AMOUNT_CHANGED", + func = "function(unit)\n local absorb = UnitGetTotalHealAbsorbs(unit) or 0\n return absorb > 0 and _VARS.E:FormatNumber(absorb) or \" \"\nend", + }, + ["ls:altpower:cur"] = { + events = "UNIT_POWER_BAR_SHOW UNIT_POWER_BAR_HIDE UNIT_POWER_UPDATE UNIT_MAXPOWER", + func = "function(unit)\n if UnitAlternatePowerInfo(unit) then\n return _VARS.E:FormatNumber(UnitPower(unit, ALTERNATE_POWER_INDEX))\n end\n\n return \"\"\nend", + }, + ["ls:altpower:cur-max"] = { + events = "UNIT_POWER_BAR_SHOW UNIT_POWER_BAR_HIDE UNIT_POWER_UPDATE UNIT_MAXPOWER", + func = "function(unit)\n if UnitAlternatePowerInfo(unit) then\n local cur, max = UnitPower(unit, ALTERNATE_POWER_INDEX), UnitPowerMax(unit, ALTERNATE_POWER_INDEX)\n if cur == max then\n return _VARS.E:FormatNumber(cur)\n else\n return string.format(\"%s - %s\", _VARS.E:FormatNumber(cur), _VARS.E:FormatNumber(max))\n end\n end\n\n return \"\"\nend", + }, + ["ls:altpower:cur-perc"] = { + events = "UNIT_POWER_BAR_SHOW UNIT_POWER_BAR_HIDE UNIT_POWER_UPDATE UNIT_MAXPOWER", + func = "function(unit)\n if UnitAlternatePowerInfo(unit) then\n local cur, max = UnitPower(unit, ALTERNATE_POWER_INDEX), UnitPowerMax(unit, ALTERNATE_POWER_INDEX)\n if cur == max then\n return _VARS.E:FormatNumber(cur)\n else\n return string.format(\"%s - %.1f%%\", _VARS.E:FormatNumber(cur), _VARS.E:NumberToPerc(cur, max))\n end\n end\n\n return \"\"\nend", + }, + ["ls:altpower:max"] = { + events = "UNIT_POWER_BAR_SHOW UNIT_POWER_BAR_HIDE UNIT_POWER_UPDATE UNIT_MAXPOWER", + func = "function(unit)\n if UnitAlternatePowerInfo(unit) then\n return _VARS.E:FormatNumber(UnitPowerMax(unit, ALTERNATE_POWER_INDEX))\n end\n\n return \"\"\nend", + }, + ["ls:altpower:perc"] = { + events = "UNIT_POWER_BAR_SHOW UNIT_POWER_BAR_HIDE UNIT_POWER_UPDATE UNIT_MAXPOWER", + func = "function(unit)\n if UnitAlternatePowerInfo(unit) then\n return string.format(\"%.1f%%\", _VARS.E:NumberToPerc(UnitPower(unit, ALTERNATE_POWER_INDEX), UnitPowerMax(unit, ALTERNATE_POWER_INDEX)))\n end\n\n return \"\"\nend", + }, + ["ls:classicon"] = { + events = "UNIT_CLASSIFICATION_CHANGED", + func = "function(unit)\n if UnitIsPlayer(unit) then\n local _, class = UnitClass(unit)\n if class then\n return _VARS.INLINE_ICONS[class]:format(0, 0)\n end\n end\n\n return \"\"\nend", + }, + ["ls:color:absorb-damage"] = { + func = "function()\n return \"|c\" .. _VARS.COLORS.prediction.damage_absorb.hex\nend", + }, + ["ls:color:absorb-heal"] = { + func = "function()\n return \"|c\" .. _VARS.COLORS.prediction.heal_absorb.hex\nend", + }, + ["ls:color:altpower"] = { + func = "function()\n return \"|c\" .. _VARS.POWER_COLORS.ALTERNATE.hex\nend", + }, + ["ls:color:class"] = { + func = "function(unit)\n if UnitIsPlayer(unit) then\n local _, class = UnitClass(unit)\n if class then\n return \"|c\" .. _VARS.CLASS_COLORS[class].hex\n end\n end\n\n return \"|cffffffff\"\nend", events = "UNIT_CLASSIFICATION_CHANGED UNIT_NAME_UPDATE", + }, + ["ls:color:difficulty"] = { + events = "UNIT_LEVEL PLAYER_LEVEL_UP", + func = "function(unit)\n return \"|c\" .. _VARS.E:GetCreatureDifficultyColor(UnitEffectiveLevel(unit)).hex\nend", + }, + ["ls:color:power"] = { + func = "function(unit)\n local type, _, r, g, b = UnitPowerType(unit)\n if not r then\n return \"|c\" .. _VARS.POWER_COLORS[type].hex\n else\n if r > 1 or g > 1 or b > 1 then\n r, g, b = r / 255, g / 255, b / 255\n end\n\n return Hex(r, g, b)\n end\nend", + }, + ["ls:color:reaction"] = { + events = "UNIT_FACTION UNIT_NAME_UPDATE", + func = "function(unit)\n local reaction = UnitReaction(unit, 'player')\n if reaction then\n return \"|c\" .. _VARS.REACTION_COLORS[reaction].hex\n end\n\n return \"|cffffffff\"\nend", + }, + ["ls:combatresticon"] = { + events = "PLAYER_UPDATE_RESTING PLAYER_REGEN_DISABLED PLAYER_REGEN_ENABLED", + func = "function()\n if UnitAffectingCombat(\"player\") then\n return _VARS.INLINE_ICONS[\"COMBAT\"]:format(0, 0)\n elseif IsResting() then\n return _VARS.INLINE_ICONS[\"RESTING\"]:format(0, 0)\n end\n\n return \"\"\nend", + }, + ["ls:debuffs"] = { + events = "UNIT_AURA", + vars = "{\n [\"Curse\"] = \"|TInterface\\\\AddOns\\\\ls_UI\\\\assets\\\\unit-frame-aura-icons:0:0:0:0:128:128:67:99:1:33|t\",\n [\"Disease\"] = \"|TInterface\\\\AddOns\\\\ls_UI\\\\assets\\\\unit-frame-aura-icons:0:0:0:0:128:128:1:33:34:66|t\",\n [\"Magic\"] = \"|TInterface\\\\AddOns\\\\ls_UI\\\\assets\\\\unit-frame-aura-icons:0:0:0:0:128:128:34:66:34:66|t\",\n [\"Poison\"] = \"|TInterface\\\\AddOns\\\\ls_UI\\\\assets\\\\unit-frame-aura-icons:0:0:0:0:128:128:67:99:34:66|t\",\n}", + func = "function(unit)\n local types = _VARS.E:GetDispelTypes()\n if not types or not UnitCanAssist(\"player\", unit) then\n return \"\"\n end\n\n local hasDebuff = {Curse = false, Disease = false, Magic = false, Poison = false}\n local status = \"\"\n\n for i = 1, 40 do\n local name, _, _, type = UnitDebuff(unit, i, \"RAID\")\n if not name then\n break\n end\n\n if types[type] and not hasDebuff[type] then\n status = status .. _VARS[\"ls:debuffs\"][type]\n hasDebuff[type] = true\n end\n end\n\n return status\nend", + }, + ["ls:health:cur"] = { + events = "UNIT_HEALTH_FREQUENT UNIT_MAXHEALTH UNIT_CONNECTION PLAYER_FLAGS_CHANGED", + func = "function(unit)\n if not UnitIsConnected(unit) then\n return _VARS.L[\"OFFLINE\"]\n elseif UnitIsDeadOrGhost(unit) then\n return _VARS.L[\"DEAD\"]\n else\n return _VARS.E:FormatNumber(UnitHealth(unit))\n end\nend", + }, + ["ls:health:cur-perc"] = { + events = "UNIT_HEALTH_FREQUENT UNIT_MAXHEALTH UNIT_CONNECTION PLAYER_FLAGS_CHANGED", + func = "function(unit)\n if not UnitIsConnected(unit) then\n return _VARS.L[\"OFFLINE\"]\n elseif UnitIsDeadOrGhost(unit) then\n return _VARS.L[\"DEAD\"]\n else\n local cur, max = UnitHealth(unit), UnitHealthMax(unit)\n if cur == max then\n return _VARS.E:FormatNumber(cur)\n else\n return string.format(\"%s - %.1f%%\", _VARS.E:FormatNumber(cur), _VARS.E:NumberToPerc(cur, max))\n end\n end\nend", + }, + ["ls:health:deficit"] = { + events = "UNIT_HEALTH_FREQUENT UNIT_MAXHEALTH UNIT_CONNECTION PLAYER_FLAGS_CHANGED", + func = "function(unit)\n if not UnitIsConnected(unit) then\n return _VARS.L[\"OFFLINE\"]\n elseif UnitIsDeadOrGhost(unit) then\n return _VARS.L[\"DEAD\"]\n else\n local cur, max = UnitHealth(unit), UnitHealthMax(unit)\n if max and cur ~= max then\n return string.format(\"-%s\", _VARS.E:FormatNumber(max - cur))\n end\n end\n\n return \"\"\nend", + }, + ["ls:health:perc"] = { + events = "UNIT_HEALTH_FREQUENT UNIT_MAXHEALTH UNIT_CONNECTION PLAYER_FLAGS_CHANGED", + func = "function(unit)\n if not UnitIsConnected(unit) then\n return _VARS.L[\"OFFLINE\"]\n elseif UnitIsDeadOrGhost(unit) then\n return _VARS.L[\"DEAD\"]\n else\n return string.format(\"%.1f%%\", _VARS.E:NumberToPerc(UnitHealth(unit), UnitHealthMax(unit)))\n end\nend", + }, + ["ls:leadericon"] = { + events = "PARTY_LEADER_CHANGED GROUP_ROSTER_UPDATE", + func = "function(unit)\n if (UnitInParty(unit) or UnitInRaid(unit)) and UnitIsGroupLeader(unit) then\n return _VARS.INLINE_ICONS[\"LEADER\"]:format(0, 0)\n end\n\n return \"\"\nend", + }, + ["ls:level"] = { + events = "UNIT_LEVEL PLAYER_LEVEL_UP", + func = "function(unit)\n local level\n\n if UnitIsWildBattlePet(unit) or UnitIsBattlePetCompanion(unit) then\n level = UnitBattlePetLevel(unit)\n else\n level = UnitLevel(unit)\n end\n\n return level > 0 and level or \"??\"\nend", + }, + ["ls:level:effective"] = { + events = "UNIT_LEVEL PLAYER_LEVEL_UP", + func = "function(unit)\n local level\n\n if UnitIsWildBattlePet(unit) or UnitIsBattlePetCompanion(unit) then\n level = UnitBattlePetLevel(unit)\n else\n level = UnitEffectiveLevel(unit)\n end\n\n return level > 0 and level or \"??\"\nend", + }, + ["ls:lfdroleicon"] = { + events = "GROUP_ROSTER_UPDATE", + func = "function(unit)\n local role = UnitGroupRolesAssigned(unit)\n if role and role ~= \"NONE\" then\n return _VARS.INLINE_ICONS[role]:format(0, 0)\n end\n\n return \"\"\nend", + }, + ["ls:name"] = { + events = "UNIT_NAME_UPDATE", + func = "function(unit)\n return UnitName(unit) or \"\"\nend", + }, + ["ls:name:10"] = { + events = "UNIT_NAME_UPDATE", + func = "function(unit)\n local name = UnitName(unit) or \"\"\n return name ~= \"\" and _VARS.E:TruncateString(name, 10) or name\nend", + }, + ["ls:name:15"] = { + events = "UNIT_NAME_UPDATE", + func = "function(unit)\n local name = UnitName(unit) or \"\"\n return name ~= \"\" and _VARS.E:TruncateString(name, 15) or name\nend", + }, + ["ls:name:20"] = { + events = "UNIT_NAME_UPDATE", + func = "function(unit)\n local name = UnitName(unit) or \"\"\n return name ~= \"\" and _VARS.E:TruncateString(name, 20) or name\nend", + }, + ["ls:name:5"] = { + events = "UNIT_NAME_UPDATE", + func = "function(unit)\n local name = UnitName(unit) or \"\"\n return name ~= \"\" and _VARS.E:TruncateString(name, 5) or name\nend", + }, + ["ls:npc:type"] = { + events = "UNIT_CLASSIFICATION_CHANGED UNIT_NAME_UPDATE", + func = "function(unit)\n local classification = UnitClassification(unit)\n if classification == \"rare\" then\n return \"R\"\n elseif classification == \"rareelite\" then\n return \"R+\"\n elseif classification == \"elite\" then\n return \"+\"\n elseif classification == \"worldboss\" then\n return \"B\"\n elseif classification == \"minus\" then\n return \"-\"\n end\n\n return \"\"\nend", + }, + ["ls:phaseicon"] = { + events = "UNIT_PHASE", + func = "function(unit)\n if (not UnitInPhase(unit) or UnitIsWarModePhased(unit)) and UnitIsPlayer(unit) and UnitIsConnected(unit) then\n if UnitIsWarModePhased(unit) then\n return _VARS.INLINE_ICONS[\"PHASE_WM\"]:format(0, 0)\n else\n return _VARS.INLINE_ICONS[\"PHASE\"]:format(0, 0)\n end\n end\n\n return \"\"\nend", + }, + ["ls:player:class"] = { + events = "UNIT_CLASSIFICATION_CHANGED", + func = "function(unit)\n if UnitIsPlayer(unit) then\n local class = UnitClass(unit)\n if class then\n return class\n end\n end\n\n return \"\"\nend", + }, + ["ls:power:cur"] = { + events = "UNIT_POWER_FREQUENT UNIT_MAXPOWER UNIT_CONNECTION PLAYER_FLAGS_CHANGED UNIT_DISPLAYPOWER", + func = "function(unit)\n if UnitIsConnected(unit) and not UnitIsDeadOrGhost(unit) then\n local type = UnitPowerType(unit)\n local max = UnitPowerMax(unit, type)\n if max and max ~= 0 then\n return _VARS.E:FormatNumber(UnitPower(unit, type))\n end\n end\n\n return \"\"\nend", + }, + ["ls:power:cur-max"] = { + events = "UNIT_POWER_FREQUENT UNIT_MAXPOWER UNIT_CONNECTION PLAYER_FLAGS_CHANGED UNIT_DISPLAYPOWER", + func = "function(unit)\n if UnitIsConnected(unit) and not UnitIsDeadOrGhost(unit) then\n local type = UnitPowerType(unit)\n local max = UnitPowerMax(unit, type)\n if max and max ~= 0 then\n local cur = UnitPower(unit, type)\n if cur == max or cur == 0 then\n return _VARS.E:FormatNumber(cur)\n else\n return string.format(\"%s - %s\", _VARS.E:FormatNumber(cur), _VARS.E:FormatNumber(max))\n end\n end\n end\n\n return \"\"\nend", + }, + ["ls:power:cur-perc"] = { + events = "UNIT_POWER_FREQUENT UNIT_MAXPOWER UNIT_CONNECTION PLAYER_FLAGS_CHANGED UNIT_DISPLAYPOWER", + func = "function(unit)\n if UnitIsConnected(unit) and not UnitIsDeadOrGhost(unit) then\n local type = UnitPowerType(unit)\n local max = UnitPowerMax(unit, type)\n if max and max ~= 0 then\n local cur = UnitPower(unit, type)\n if cur == 0 or cur == max then\n return _VARS.E:FormatNumber(cur)\n else\n return string.format(\"%s - %.1f%%\", _VARS.E:FormatNumber(cur), _VARS.E:NumberToPerc(cur, max))\n end\n end\n end\n\n return \"\"\nend", + }, + ["ls:power:deficit"] = { + events = "UNIT_POWER_FREQUENT UNIT_MAXPOWER UNIT_CONNECTION PLAYER_FLAGS_CHANGED UNIT_DISPLAYPOWER", + func = "function(unit)\n if UnitIsConnected(unit) and not UnitIsDeadOrGhost(unit) then\n local type = UnitPowerType(unit)\n local cur, max = UnitPower(unit, type), UnitPowerMax(unit, type)\n if max and cur ~= max then\n return string.format(\"-%s\", _VARS.E:FormatNumber(max - cur))\n end\n end\n\n return \"\"\nend", + }, + ["ls:power:max"] = { + events = "UNIT_POWER_FREQUENT UNIT_MAXPOWER UNIT_CONNECTION PLAYER_FLAGS_CHANGED UNIT_DISPLAYPOWER", + func = "function(unit)\n if UnitIsConnected(unit) and not UnitIsDeadOrGhost(unit) then\n local type = UnitPowerType(unit)\n local max = UnitPowerMax(unit, type)\n if max and max ~= 0 then\n return _VARS.E:FormatNumber(max)\n end\n end\n\n return \"\"\nend", + }, + ["ls:power:perc"] = { + events = "UNIT_POWER_FREQUENT UNIT_MAXPOWER UNIT_CONNECTION PLAYER_FLAGS_CHANGED UNIT_DISPLAYPOWER", + func = "function(unit)\n if UnitIsConnected(unit) and not UnitIsDeadOrGhost(unit) then\n local type = UnitPowerType(unit)\n local max = UnitPowerMax(unit, type)\n if max and max ~= 0 then\n return string.format(\"%.1f%%\", _VARS.E:NumberToPerc(UnitPower(unit, type), max))\n end\n end\n\n return \"\"\nend", + }, + ["ls:pvptimer"] = { + func = "function()\n if IsPVPTimerRunning() then\n local remain = GetPVPTimer() / 1000\n if remain >= 1 then\n local time1, time2, format\n\n if remain >= 60 then\n time1, time2, format = _VARS.E:SecondsToTime(remain, \"x:xx\")\n else\n time1, time2, format = _VARS.E:SecondsToTime(remain)\n end\n\n return format:format(time1, time2)\n end\n end\nend", + }, + ["ls:questicon"] = { + events = "UNIT_CLASSIFICATION_CHANGED", + func = "function(unit)\n if UnitIsQuestBoss(unit) then\n return _VARS.INLINE_ICONS[\"QUEST\"]:format(0, 0)\n end\n\n return \"\"\nend", + }, + ["ls:server"] = { + events = "UNIT_NAME_UPDATE", + func = "function(unit)\n local _, realm = UnitName(unit)\n if realm and realm ~= \"\" then\n local relationship = UnitRealmRelationship(unit)\n if relationship ~= LE_REALM_RELATION_VIRTUAL then\n return _VARS.L[\"FOREIGN_SERVER_LABEL\"]\n end\n end\n\n return \"\"\nend", + }, + ["ls:sheepicon"] = { + events = "UNIT_CLASSIFICATION_CHANGED", + vars = "{\n [\"Beast\"] = true,\n [\"Bestia\"] = true,\n [\"Bête\"] = true,\n [\"Fera\"] = true,\n [\"Humanoid\"] = true,\n [\"Humanoide\"] = true,\n [\"Humanoïde\"] = true,\n [\"Umanoide\"] = true,\n [\"Wildtier\"] = true,\n [\"Гуманоид\"] = true,\n [\"Животное\"] = true,\n [\"야수\"] = true,\n [\"인간형\"] = true,\n [\"人型生物\"] = true,\n [\"人形生物\"] = true,\n [\"野兽\"] = true,\n [\"野獸\"] = true,\n}", + func = "function(unit)\n if (_VARS.E.PLAYER_CLASS == \"MAGE\" or _VARS.E.PLAYER_CLASS == \"SHAMAN\")\n and UnitCanAttack(\"player\", unit) and (UnitIsPlayer(unit) or _VARS[\"ls:sheepicon\"][UnitCreatureType(unit)]) then\n return _VARS.INLINE_ICONS[\"SHEEP\"]:format(0, 0)\n end\n\n return \"\"\nend", + }, + ["nl"] = { + func = "function()\n return \"\\n\"\nend", + }, + }, + tag_vars = { + ["E"] = "ls_UI[1]", + ["M"] = "ls_UI[2]", + ["C"] = "ls_UI[3]", + ["L"] = "ls_UI[4]", + ["INLINE_ICONS"] = "ls_UI[2].textures.inlineicons", + ["COLORS"] = "ls_UI[3].db.global.colors", + ["CLASS_COLORS"] = "ls_UI[3].db.global.colors.class", + ["POWER_COLORS"] = "ls_UI[3].db.global.colors.power", + ["REACTION_COLORS"] = "ls_UI[3].db.global.colors.reaction", + }, } D.profile = { diff --git a/modules/unitframes/core.lua b/modules/unitframes/core.lua index 6af97dbc..99abac56 100644 --- a/modules/unitframes/core.lua +++ b/modules/unitframes/core.lua @@ -153,6 +153,9 @@ function UF:UpdatePowerColors() end function UF:UpdateTags() + oUF.Tags.SharedEvents["PLAYER_REGEN_DISABLED"] = true + oUF.Tags.SharedEvents["PLAYER_REGEN_ENABLED"] = true + for name, data in next, C.db.global.tags do oUF.Tags.Events[name] = data.events diff --git a/modules/unitframes/elements/_elements.xml b/modules/unitframes/elements/_elements.xml index 48cce051..d213425f 100644 --- a/modules/unitframes/elements/_elements.xml +++ b/modules/unitframes/elements/_elements.xml @@ -10,6 +10,5 @@