From 61639abf92e11997eb6e0a39ffb0da7a0dc69f59 Mon Sep 17 00:00:00 2001 From: noname08662 <178931709+noname08662@users.noreply.github.com> Date: Thu, 30 Jan 2025 16:52:09 +0200 Subject: [PATCH] Add files via upload --- ElvUI_Extras.lua | 2 +- Locales/deDE.lua | 4 +- Locales/enUS.lua | 5 +- Locales/esMX.lua | 5 +- Locales/frFR.lua | 4 +- Locales/koKR.lua | 4 +- Locales/ptBR.lua | 4 +- Locales/ruRU.lua | 4 +- Locales/zhCN.lua | 4 +- Locales/zhTW.lua | 4 +- Modules/Nameplates/Auras.lua | 6 +- Modules/Nameplates/Cooldowns.lua | 125 +++++++++++++++++++------------ Modules/Unitframes/Cooldowns.lua | 94 ++++++++++++++++------- 13 files changed, 175 insertions(+), 90 deletions(-) diff --git a/ElvUI_Extras.lua b/ElvUI_Extras.lua index 3dd74f4..74876d0 100644 --- a/ElvUI_Extras.lua +++ b/ElvUI_Extras.lua @@ -102,9 +102,9 @@ core.SpellLists = { [50334] = 180, -- Berserk [50516] = 17, -- Typhoon [33831] = 180, -- Force of Nature - [53201] = 60, -- Starfall [8983] = 50, -- Bash [29166] = 180, -- Innervate + -- [53201] = 60, -- Starfall -- [22570] = 10, -- Maim -- [18562] = 15, -- Swiftmend -- [22842] = 180, -- Frenzied Regeneration diff --git a/Locales/deDE.lua b/Locales/deDE.lua index d2fa727..37ccca2 100644 --- a/Locales/deDE.lua +++ b/Locales/deDE.lua @@ -408,7 +408,6 @@ L["Remove Texture"] = "Textur entfernen" L["Highlights"] = "Hervorhebungen" L["Select Type"] = "Typ auswählen" L["Highlights Settings"] = "Einstellungen für Hervorhebungen" -L["Add Spell (by ID)"] = "Zauber hinzufügen (nach ID)" L["Add Filter"] = "Filter hinzufügen" L["Remove Selected"] = "Ausgewählte entfernen" L["Select Spell or Filter"] = "Zauber oder Filter auswählen" @@ -1137,3 +1136,6 @@ L["Add Item (ID)"] = "Artikel hinzufügen (ID)" L["Item Text"] = "Artikeltext" L["Sort by Filter"] = "Nach Filter sortieren" L["Makes aura sorting abide filter priorities."] = "Sortiert Auren gemäß der Filterprioritäten." +L["Add Spell"] = "Zauber hinzufügen" +L["Format: 'spellID cooldown time',\ne.g. 42292 120\nor\nSpellName 20"] = + "Format: 'ZauberID Abklingzeit',\nz. B. 42292 120\noder\nZauberName 20" diff --git a/Locales/enUS.lua b/Locales/enUS.lua index b245f73..d974baa 100644 --- a/Locales/enUS.lua +++ b/Locales/enUS.lua @@ -301,7 +301,6 @@ L["Remove Texture"] = true L["Highlights"] = true L["Select Type"] = true L["Highlights Settings"] = true -L["Add Spell (by ID)"] = true L["Add Filter"] = true L["Remove Selected"] = true L["Select Spell or Filter"] = true @@ -925,4 +924,6 @@ L["Select Item"] = true L["Add Item (ID)"] = true L["Item Text"] = true L["Sort by Filter"] = true -L["Makes aura sorting abide filter priorities."] = true \ No newline at end of file +L["Makes aura sorting abide filter priorities."] = true +L["Add Spell"] = true +L["Format: 'spellID cooldown time',\ne.g. 42292 120\nor\nSpellName 20"] = true \ No newline at end of file diff --git a/Locales/esMX.lua b/Locales/esMX.lua index 209434e..388a6db 100644 --- a/Locales/esMX.lua +++ b/Locales/esMX.lua @@ -411,7 +411,6 @@ L["Remove Texture"] = "Eliminar Textura" L["Highlights"] = "Destacar" L["Select Type"] = "Seleccionar Tipo" L["Highlights Settings"] = "Configuraciones de Destacar" -L["Add Spell (by ID)"] = "Agregar Hechizo (por ID)" L["Add Filter"] = "Agregar Filtro" L["Remove Selected"] = "Eliminar Seleccionado" L["Select Spell or Filter"] = "Seleccionar Hechizo o Filtro" @@ -1142,4 +1141,6 @@ L["Add Item (ID)"] = "Agregar artículo (ID)" L["Item Text"] = "Texto del artículo" L["Sort by Filter"] = "Ordenar por filtro" L["Makes aura sorting abide filter priorities."] = "Hace que la ordenación de auras respete las prioridades del filtro." - +L["Add Spell"] = "Añadir hechizo" +L["Format: 'spellID cooldown time',\ne.g. 42292 120\nor\nSpellName 20"] = + "Formato: 'ID de hechizo tiempo de reutilización',\np. ej. 42292 120\no\nNombreHechizo 20" \ No newline at end of file diff --git a/Locales/frFR.lua b/Locales/frFR.lua index 814a58f..40c6ddc 100644 --- a/Locales/frFR.lua +++ b/Locales/frFR.lua @@ -411,7 +411,6 @@ L["Remove Texture"] = "Supprimer une texture" L["Highlights"] = "Surbrillance" L["Select Type"] = "Sélectionner le Type" L["Highlights Settings"] = "Paramètres de Surbrillance" -L["Add Spell (by ID)"] = "Ajouter un Sort (par ID)" L["Add Filter"] = "Ajouter un Filtre" L["Remove Selected"] = "Supprimer la Sélection" L["Select Spell or Filter"] = "Sélectionner un Sort ou un Filtre" @@ -1143,3 +1142,6 @@ L["Add Item (ID)"] = "Ajouter un article (ID)" L["Item Text"] = "Texte de l'article" L["Sort by Filter"] = "Trier par filtre" L["Makes aura sorting abide filter priorities."] = "Fait en sorte que le tri des auras respecte les priorités des filtres." +L["Add Spell"] = "Ajouter un sort" +L["Format: 'spellID cooldown time',\ne.g. 42292 120\nor\nSpellName 20"] = + "Format : 'IDSort TempsRecharge',\nex. 42292 120\nou\nNomSort 20" diff --git a/Locales/koKR.lua b/Locales/koKR.lua index 341a7cb..39daefa 100644 --- a/Locales/koKR.lua +++ b/Locales/koKR.lua @@ -411,7 +411,6 @@ L["Remove Texture"] = "텍스처 제거" L["Highlights"] = "강조" L["Select Type"] = "유형 선택" L["Highlights Settings"] = "강조 설정" -L["Add Spell (by ID)"] = "주문 추가 (ID로)" L["Add Filter"] = "필터 추가" L["Remove Selected"] = "선택 항목 제거" L["Select Spell or Filter"] = "주문 또는 필터 선택" @@ -1141,3 +1140,6 @@ L["Add Item (ID)"] = "아이템 추가 (ID)" L["Item Text"] = "아이템 텍스트" L["Sort by Filter"] = "필터별 정렬" L["Makes aura sorting abide filter priorities."] = "오라 정렬이 필터 우선순위를 따르도록 설정합니다." +L["Add Spell"] = "주문 추가" +L["Format: 'spellID cooldown time',\ne.g. 42292 120\nor\nSpellName 20"] = + "형식: '주문ID 재사용 대기시간',\n예: 42292 120\n또는\n주문이름 20" diff --git a/Locales/ptBR.lua b/Locales/ptBR.lua index fe119d7..2caf7ef 100644 --- a/Locales/ptBR.lua +++ b/Locales/ptBR.lua @@ -411,7 +411,6 @@ L["Remove Texture"] = "Remover Textura" L["Highlights"] = "Destaques" L["Select Type"] = "Selecionar Tipo" L["Highlights Settings"] = "Configurações de Destaques" -L["Add Spell (by ID)"] = "Adicionar Feitiço (por ID)" L["Add Filter"] = "Adicionar Filtro" L["Remove Selected"] = "Remover Selecionado" L["Select Spell or Filter"] = "Selecionar Feitiço ou Filtro" @@ -1140,3 +1139,6 @@ L["Add Item (ID)"] = "Adicionar item (ID)" L["Item Text"] = "Texto do item" L["Sort by Filter"] = "Ordenar por filtro" L["Makes aura sorting abide filter priorities."] = "Faz com que a organização de auras siga as prioridades do filtro." +L["Add Spell"] = "Adicionar feitiço" +L["Format: 'spellID cooldown time',\ne.g. 42292 120\nor\nSpellName 20"] = + "Formato: 'IDFeitiço tempo de recarga',\nex: 42292 120\nou\nNomeFeitiço 20" \ No newline at end of file diff --git a/Locales/ruRU.lua b/Locales/ruRU.lua index 57af042..50a2764 100644 --- a/Locales/ruRU.lua +++ b/Locales/ruRU.lua @@ -412,7 +412,6 @@ L["Remove Texture"] = "Удалить текстуру" L["Highlights"] = "Подсветка" L["Select Type"] = "Выбрать Тип" L["Highlights Settings"] = "Настройки Подсветки" -L["Add Spell (by ID)"] = "Добавить Заклинание (по ID)" L["Add Filter"] = "Добавить Фильтр" L["Remove Selected"] = "Удалить Выбранное" L["Select Spell or Filter"] = "Выбрать Заклинание или Фильтр" @@ -1141,3 +1140,6 @@ L["Add Item (ID)"] = "Добавить предмет (ID)" L["Item Text"] = "Текст предмета" L["Sort by Filter"] = "Сортировка по фильтру" L["Makes aura sorting abide filter priorities."] = "Сортировка аур в соответствии с приоритетами фильтра." +L["Add Spell"] = "Добавить заклинание" +L["Format: 'spellID cooldown time',\ne.g. 42292 120\nor\nSpellName 20"] = + "Формат: 'ID заклинания время восстановления',\nнапример, 42292 120\nили\nНазваниеЗаклинания 20" diff --git a/Locales/zhCN.lua b/Locales/zhCN.lua index a3ec4b7..44abc40 100644 --- a/Locales/zhCN.lua +++ b/Locales/zhCN.lua @@ -411,7 +411,6 @@ L["Remove Texture"] = "移除纹理" L["Highlights"] = "高亮" L["Select Type"] = "选择类型" L["Highlights Settings"] = "高亮设置" -L["Add Spell (by ID)"] = "添加法术(按ID)" L["Add Filter"] = "添加过滤器" L["Remove Selected"] = "移除选中" L["Select Spell or Filter"] = "选择法术或过滤器" @@ -1137,3 +1136,6 @@ L["Add Item (ID)"] = "添加物品 (ID)" L["Item Text"] = "物品文本" L["Sort by Filter"] = "按过滤器排序" L["Makes aura sorting abide filter priorities."] = "使光环排序遵循过滤器优先级。" +L["Add Spell"] = "添加法术" +L["Format: 'spellID cooldown time',\ne.g. 42292 120\nor\nSpellName 20"] = + "格式: '法术ID 冷却时间',\n例如 42292 120\n或\n法术名称 20" diff --git a/Locales/zhTW.lua b/Locales/zhTW.lua index 00b028b..bff1491 100644 --- a/Locales/zhTW.lua +++ b/Locales/zhTW.lua @@ -411,7 +411,6 @@ L["Remove Texture"] = "移除材質" L["Highlights"] = "重點" L["Select Type"] = "選擇類型" L["Highlights Settings"] = "重點設置" -L["Add Spell (by ID)"] = "添加法術(按ID)" L["Add Filter"] = "添加過濾器" L["Remove Selected"] = "移除選擇" L["Select Spell or Filter"] = "選擇法術或過濾器" @@ -1137,3 +1136,6 @@ L["Add Item (ID)"] = "添加物品 (ID)" L["Item Text"] = "物品文字" L["Sort by Filter"] = "依過濾條件排序" L["Makes aura sorting abide filter priorities."] = "使光環排序遵循過濾條件的優先順序。" +L["Add Spell"] = "添加法術" +L["Format: 'spellID cooldown time',\ne.g. 42292 120\nor\nSpellName 20"] = + "格式: '法術ID 冷卻時間',\n例如 42292 120\n或\n法術名稱 20" diff --git a/Modules/Nameplates/Auras.lua b/Modules/Nameplates/Auras.lua index f7b9551..b898b24 100644 --- a/Modules/Nameplates/Auras.lua +++ b/Modules/Nameplates/Auras.lua @@ -11,7 +11,7 @@ local iconPositions = {} local pairs, ipairs, unpack, type, tonumber, tostring = pairs, ipairs, unpack, type, tonumber, tostring local tinsert, tsort, twipe = table.insert, table.sort, table.wipe local floor, ceil, min, max, abs = math.floor, math.ceil, math.min, math.max, math.abs -local find, gmatch, match, gsub, format, split = string.find, string.gmatch, string.match, string.gsub, string.format, string.split +local find, gmatch, match, gsub, format, split, trim = string.find, string.gmatch, string.match, string.gsub, string.format, string.split, string.trim local GetTime, DebuffTypeColor, UnitCanAttack, GetSpellInfo, GetSpellLink, CreateFrame = GetTime, DebuffTypeColor, UnitCanAttack, GetSpellInfo, GetSpellLink, CreateFrame local dispellList, purgeList = core.DispellList[E.myclass], core.PurgeList[E.myclass] @@ -527,7 +527,7 @@ function mod:LoadConfig(db) desc = L["E.g. 42292"], get = function() return "" end, set = function(_, value) - local spellID = match(value, '%D*(%d+)%D*') + local spellID = trim(match(value, '%D*(%d+)%D*')) if spellID and GetSpellInfo(spellID) then db.Highlights.types[selectedType()].spellList[tonumber(spellID)] = { ["border"] = false, @@ -1151,7 +1151,7 @@ function mod:SetAura(frame, guid, index, filter, isDebuff, visible) if not db.enabled then return end local dtype = button.dtype - local dbSpell = db.spellList[spellID] + local dbSpell = db.spellList[spellID] or db.spellList[name] local unstableAffliction = GetSpellInfo(30108) local vampiricTouch = GetSpellInfo(34914) if dbSpell then diff --git a/Modules/Nameplates/Cooldowns.lua b/Modules/Nameplates/Cooldowns.lua index d37f947..230be14 100644 --- a/Modules/Nameplates/Cooldowns.lua +++ b/Modules/Nameplates/Cooldowns.lua @@ -15,7 +15,7 @@ local band = bit.band local _G, pairs, ipairs, select, unpack, next = _G, pairs, ipairs, select, unpack, next local tonumber, tostring, loadstring, setfenv = tonumber, tostring, loadstring, setfenv local gsub, upper, match, find, format = string.gsub, string.upper, string.match, string.find, string.format -local random, floor, min, ceil = math.random, math.floor, math.min, math.ceil +local random, floor, min, ceil, abs = math.random, math.floor, math.min, math.ceil, math.abs local tinsert, tremove, tsort, twipe = table.insert, table.remove, table.sort, table.wipe local GetSpellInfo, GetSpellLink, GetTime = GetSpellInfo, GetSpellLink, GetTime local UnitIsPlayer, UnitExists, UnitName = UnitIsPlayer, UnitExists, UnitName @@ -390,7 +390,9 @@ local function cache(db, visibilityUpdate) if not visibilityUpdate then twipe(highlightedSpells[unitType]) for spellID, info in pairs(type_db.highlightedSpells) do - highlightedSpells[unitType][spellID] = info + if info.enabled then + highlightedSpells[unitType][spellID] = info + end end local icons = type_db.icons @@ -539,10 +541,13 @@ P["Extras"]["nameplates"][modName] = { function mod:LoadConfig(db) local function selectedType() return db.selectedType end - local function selectedSpell() return selectedType() and tonumber(db[selectedType()].selectedSpell) or "" end + local function selectedSpell() return selectedType() and tonumber(db[selectedType()].selectedSpell) or db[selectedType()].selectedSpell or "" end local function selectedTypeData() return core:getSelected("nameplates", modName, format("[%s]", selectedType() or ""), "FRIENDLY_PLAYER") end + local function highlightedSpellsData() + return core:getSelected("nameplates", modName, format("%s.highlightedSpells[%s]", selectedType(), selectedSpell()), "") + end core.nameplates.args[modName] = { type = "group", name = L["Cooldowns"], @@ -945,18 +950,24 @@ function mod:LoadConfig(db) addSpell = { order = 1, type = "input", - name = L["Add Spell (by ID)"], - desc = L["Format: 'spellID cooldown time', e.g. 42292 120"], + name = L["Add Spell"], + desc = L["Format: 'spellID cooldown time',\ne.g. 42292 120\nor\nSpellName 20"], get = function() return "" end, set = function(_, value) - local spellID, cooldownTime = match(value, '%D*(%d+)%D*(%d*)') - if spellID and GetSpellInfo(spellID) then + local spellID, cooldownTime = match(value, '(.*)%s+(%d*)') + if spellID then cooldownTime = tonumber(cooldownTime) or LAI.spellDuration[spellID] if not cooldownTime then return end - selectedTypeData().spellList[tonumber(spellID)] = cooldownTime - allSpells[tonumber(spellID)] = cooldownTime + selectedTypeData().spellList[tonumber(spellID) or spellID] = cooldownTime + allSpells[tonumber(spellID) or spellID] = cooldownTime + local string local _, _, icon = GetSpellInfo(spellID) - local string = '\124T' .. gsub(icon, '\124', '\124\124') .. ':16:16\124t' .. GetSpellLink(spellID) + if icon then + icon = gsub(icon or "", '\124', '\124\124') + string = '\124T' .. icon .. ':16:16\124t' .. GetSpellLink(spellID) + else + string = format("[%s]", spellID) + end core:print('ADDED', string) NP:ForEachVisiblePlate("UpdateAllFrame", nil, true) end @@ -970,9 +981,16 @@ function mod:LoadConfig(db) func = function() local spellID = selectedSpell() selectedTypeData().spellList[spellID] = nil + db[selectedType()].selectedSpell = "" allSpells[spellID] = nil + local string local _, _, icon = GetSpellInfo(spellID) - local string = '\124T' .. gsub(icon, '\124', '\124\124') .. ':16:16\124t' .. GetSpellLink(spellID) + if icon then + icon = gsub(icon or "", '\124', '\124\124') + string = '\124T' .. icon .. ':16:16\124t' .. GetSpellLink(spellID) + else + string = format("[%s]", spellID) + end core:print('REMOVED', string) NP:ForEachVisiblePlate("UpdateAllFrame", nil, true) end, @@ -986,7 +1004,11 @@ function mod:LoadConfig(db) desc = "", get = function() return "" end, set = function(_, value) - selectedTypeData().spellList = CopyTable(core.SpellLists[value] or db[value].spellList) + local list = selectedTypeData().spellList + twipe(list) + for id, cdTime in pairs(core.SpellLists[value] or db[value].spellList) do + list[id == 47860 and id or GetSpellInfo(id)] = cdTime + end cache(db) end, values = function() @@ -1032,7 +1054,7 @@ function mod:LoadConfig(db) width = "double", name = L["Select Spell"], desc = "", - get = function(info) return selectedTypeData()[info[#info]] end, + get = function() return selectedSpell() end, set = function(info, value) selectedTypeData()[info[#info]] = value if not selectedTypeData().highlightedSpells[selectedSpell()] then @@ -1044,9 +1066,16 @@ function mod:LoadConfig(db) values = function() local values = {} for id in pairs(selectedTypeData().spellList) do - local name = GetSpellInfo(id) or "" - local icon = select(3, GetSpellInfo(id)) - values[id] = format("%s %s (%s)", icon and "|T"..icon..":0|t" or "", name, id) + if type(id) == 'number' then + local name = GetSpellInfo(id) or "" + local icon = select(3, GetSpellInfo(id)) + icon = icon and "|T"..icon..":0|t" or "" + values[id] = format("%s %s (%s)", icon, name, id) + else + local icon = select(3, GetSpellInfo(id)) + icon = icon and "|T"..icon..":0|t" or "" + values[id] = format("%s %s", icon, id) + end end return values end, @@ -1056,7 +1085,17 @@ function mod:LoadConfig(db) tinsert(sortedKeys, id) end tsort(sortedKeys, function(a, b) - return (GetSpellInfo(a) or "") < (GetSpellInfo(b) or "") + local nameA = GetSpellInfo(a) + local nameB = GetSpellInfo(b) + if not nameA and not nameB then + return a < b + elseif not nameB then + return true + elseif not nameA then + return false + else + return nameA < nameB + end end) return sortedKeys end, @@ -1067,15 +1106,12 @@ function mod:LoadConfig(db) width = "full", name = L["Shadow"], desc = L["For the important stuff."], - get = function() - return selectedTypeData().highlightedSpells[selectedSpell()] - and selectedTypeData().highlightedSpells[selectedSpell()].enabled - end, + get = function() return selectedSpell() ~= "" and highlightedSpellsData().enabled end, set = function(_, value) - selectedTypeData().highlightedSpells[selectedSpell()].enabled = value + highlightedSpellsData().enabled = value NP:ForEachVisiblePlate("UpdateAllFrame", nil, true) end, - disabled = function() return not (selectedTypeData().enabled and selectedSpell()) end, + disabled = function() return not selectedTypeData().enabled or selectedSpell() == "" end, }, shadowSize = { order = 6, @@ -1083,18 +1119,14 @@ function mod:LoadConfig(db) name = L["Shadow Size"], desc = "", min = 1, max = 12, step = 1, - get = function() - return selectedTypeData().highlightedSpells[selectedSpell()] - and selectedTypeData().highlightedSpells[selectedSpell()].size or 0 - end, + get = function() return selectedSpell() ~= "" and highlightedSpellsData().size or 0 end, set = function(_, value) - selectedTypeData().highlightedSpells[selectedSpell()].size = value + highlightedSpellsData().size = value NP:ForEachVisiblePlate("UpdateAllFrame", nil, true) end, hidden = function() - return not selectedTypeData().enabled - or not selectedTypeData().highlightedSpells[selectedSpell()] - or not selectedTypeData().highlightedSpells[selectedSpell()].enabled end, + return not selectedTypeData().enabled or selectedSpell() == "" or not highlightedSpellsData().enabled + end, }, shadowColor = { order = 7, @@ -1102,25 +1134,23 @@ function mod:LoadConfig(db) hasAlpha = true, name = L["Shadow Color"], desc = "", - get = function() - return unpack(selectedTypeData().highlightedSpells[selectedSpell()] - and selectedTypeData().highlightedSpells[selectedSpell()].color or {}) - end, + get = function() return unpack(selectedSpell() ~= "" and highlightedSpellsData().color or {}) end, set = function(_, r, g, b, a) - selectedTypeData().highlightedSpells[selectedSpell()].color = { r, g, b, a } + highlightedSpellsData().color = {r, g, b, a} NP:ForEachVisiblePlate("UpdateAllFrame", nil, true) end, hidden = function() - return not selectedTypeData().enabled - or not selectedTypeData().highlightedSpells[selectedSpell()] - or not selectedTypeData().highlightedSpells[selectedSpell()].enabled end, + return not selectedTypeData().enabled or selectedSpell() == "" or not highlightedSpellsData().enabled + end, }, }, }, }, } if not next(db['FRIENDLY_PLAYER'].spellList) then - db['FRIENDLY_PLAYER'].spellList = CopyTable(core.SpellLists["DEFAULTS"]) + for id, cdTime in pairs(core.SpellLists["DEFAULTS"]) do + db['FRIENDLY_PLAYER'].spellList[id == 47860 and id or GetSpellInfo(id)] = cdTime + end end if not db['ENEMY_PLAYER'] then db['ENEMY_PLAYER'] = CopyTable(db['FRIENDLY_PLAYER']) @@ -1132,7 +1162,7 @@ local function combatLogEvent(_, ...) local _, eventType, _, sourceName, sourceFlags, _, _, _, spellID = ... if eventType == "SPELL_CAST_SUCCESS" and sourceName then - local cdTime = allSpells[spellID] + local cdTime = allSpells[spellID] or allSpells[GetSpellInfo(spellID)] local isPlayer = band(sourceFlags, COMBATLOG_OBJECT_TYPE_PLAYER) == COMBATLOG_OBJECT_TYPE_PLAYER if cdTime and (isPlayer or band(sourceFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) == COMBATLOG_OBJECT_CONTROL_PLAYER) then local startTime = GetTime() @@ -1160,12 +1190,14 @@ function mod:UpdateCooldowns(playerName, spellID, startTime, endTime, isPlayer) end end end + local name, _, icon = GetSpellInfo(spellID) tinsert(activeCds, { spellID = spellID, + spellName = name, startTime = startTime, endTime = endTime, - icon = select(3, GetSpellInfo(spellID)), + icon = icon, isTrinket = trinkets[spellID] }) self:UpdatePlates(playerName, isPlayer, hash) @@ -1235,7 +1267,7 @@ function mod:AttachCooldowns(plate, cooldowns, unitType) local maxShown = db_icons.perRow * db_icons.maxRows for _, cd in ipairs(cooldowns) do - if db_spellList[cd.spellID] then + if db_spellList[cd.spellID] or db_spellList[cd.spellName] then if shown >= maxShown then break end local cdFrame = tracker.cooldowns[shown+1] @@ -1289,9 +1321,11 @@ function mod:AttachCooldowns(plate, cooldowns, unitType) end end end + local highlights = highlightedSpells[unitType] cdFrame.endTime = endTime cdFrame.startTime = startTime cdFrame.cooldowns = cooldowns + cdFrame.highlight = highlights[cd.spellID] and highlights[cd.spellID] or highlights[cd.spellName] cdFrame.texture:SetTexture(cd.icon) cdFrame:SetScript("OnUpdate", onUpdates[unitType]) @@ -1311,7 +1345,6 @@ function mod:AttachCooldowns(plate, cooldowns, unitType) end function mod:RepositionIcons(tracker, shown, unitType) - local highlights = highlightedSpells[unitType] local info = iconPositions[unitType][shown] local iconPos = info.positions local cooldowns = tracker.cooldowns @@ -1323,8 +1356,8 @@ function mod:RepositionIcons(tracker, shown, unitType) local position = iconPos[i] cdFrame:Point(position.point, tracker, position.point, position.xOffset, position.yOffset) - local highlight = highlights[cdFrame.spellID] - if highlight and highlight.enabled then + local highlight = cdFrame.highlight + if highlight then cdFrame.shadow:SetOutside(cdFrame, highlight.size, highlight.size) cdFrame.shadow:SetBackdrop({edgeFile = edgeFile, edgeSize = E:Scale(highlight.size)}) cdFrame.shadow:SetBackdropBorderColor(unpack(highlight.color)) diff --git a/Modules/Unitframes/Cooldowns.lua b/Modules/Unitframes/Cooldowns.lua index 4431e9e..5664edd 100644 --- a/Modules/Unitframes/Cooldowns.lua +++ b/Modules/Unitframes/Cooldowns.lua @@ -60,7 +60,7 @@ scanTool:SetOwner(WorldFrame, "ANCHOR_NONE") local band = bit.band local _G, pairs, ipairs, select, unpack, next = _G, pairs, ipairs, select, unpack, next local tonumber, tostring, loadstring, setfenv = tonumber, tostring, loadstring, setfenv -local gsub, upper, match, find, format = string.gsub, string.upper, string.match, string.find, string.format +local gsub, upper, match, find, format, trim = string.gsub, string.upper, string.match, string.find, string.format, string.trim local random, floor, min, ceil, abs = math.random, math.floor, math.min, math.ceil, math.abs local tinsert, tremove, tsort, twipe, tcontains = table.insert, table.remove, table.sort, table.wipe, tContains local GetTime, CooldownFrame_SetTimer = GetTime, CooldownFrame_SetTimer @@ -619,7 +619,7 @@ P["Extras"]["unitframes"][modName] = { function mod:LoadConfig(db) local function selectedUnit() return db.selectedUnit end local function selectedType() return db.selectedType end - local function selectedSpell() return selectedType() and tonumber(db[selectedType()].selectedSpell) or "" end + local function selectedSpell() return selectedType() and tonumber(db[selectedType()].selectedSpell) or db[selectedType()].selectedSpell or "" end local function selectedTypeData() return core:getSelected("unitframes", modName, format("[%s]", selectedType() or ""), "FRIENDLY_PLAYER") end @@ -1053,20 +1053,24 @@ function mod:LoadConfig(db) addSpell = { order = 1, type = "input", - name = L["Add Spell (by ID)"], - desc = L["Format: 'spellID cooldown time', e.g. 42292 120"], + name = L["Add Spell"], + desc = L["Format: 'spellID cooldown time',\ne.g. 42292 120\nor\nSpellName 20"], get = function() return "" end, set = function(_, value) - local spellID, cooldownTime = match(value, '%D*(%d+)%D*(%d*)') - if spellID and GetSpellInfo(spellID) then + local spellID, cooldownTime = trim(match(value, '(.*)%s+(%d*)')) + if spellID then cooldownTime = tonumber(cooldownTime) or LAI.spellDuration[spellID] if not cooldownTime then return end - selectedUnitData().spellList[tonumber(spellID)] = cooldownTime - allSpells[tonumber(spellID)] = cooldownTime + selectedUnitData().spellList[tonumber(spellID) or spellID] = cooldownTime + allSpells[tonumber(spellID) or spellID] = cooldownTime + local string local _, _, icon = GetSpellInfo(spellID) - local link = GetSpellLink(spellID) - icon = gsub(icon, '\124', '\124\124') - local string = '\124T' .. icon .. ':16:16\124t' .. link + if icon then + icon = gsub(icon or "", '\124', '\124\124') + string = '\124T' .. icon .. ':16:16\124t' .. GetSpellLink(spellID) + else + string = format("[%s]", spellID) + end core:print('ADDED', string) end end, @@ -1079,11 +1083,16 @@ function mod:LoadConfig(db) func = function() local spellID = selectedSpell() selectedUnitData().spellList[spellID] = nil + db[selectedType()].selectedSpell = "" allSpells[spellID] = nil + local string local _, _, icon = GetSpellInfo(spellID) - local link = GetSpellLink(spellID) - icon = gsub(icon, '\124', '\124\124') - local string = '\124T' .. icon .. ':16:16\124t' .. link + if icon then + icon = gsub(icon or "", '\124', '\124\124') + string = '\124T' .. icon .. ':16:16\124t' .. GetSpellLink(spellID) + else + string = format("[%s]", spellID) + end core:print('REMOVED', string) end, disabled = function() return not selectedUnitData().spellList[selectedSpell()] end, @@ -1097,7 +1106,11 @@ function mod:LoadConfig(db) get = function() return "" end, set = function(_, value) if core.SpellLists[value] then - selectedUnitData().spellList = CopyTable(core.SpellLists[value]) + local list = selectedUnitData().spellList + twipe(list) + for id, cdTime in pairs(core.SpellLists[value]) do + list[id == 47860 and id or GetSpellInfo(id)] = cdTime + end else local unit, unitType = match(value, "(%l+)(.+)") selectedUnitData().spellList = CopyTable(db[unitType].units[unit].spellList) @@ -1159,7 +1172,7 @@ function mod:LoadConfig(db) width = "double", name = L["Select Spell"], desc = "", - get = function(info) return selectedUnitData()[info[#info]] end, + get = function() return selectedSpell() end, set = function(info, value) selectedTypeData()[info[#info]] = value if not selectedTypeData().highlightedSpells[selectedSpell()] then @@ -1169,10 +1182,16 @@ function mod:LoadConfig(db) values = function() local values = {} for id in pairs(selectedUnitData().spellList) do - local name = GetSpellInfo(id) or "" - local icon = select(3, GetSpellInfo(id)) - icon = icon and "|T"..icon..":0|t" or "" - values[id] = format("%s %s (%s)", icon, name, id) + if type(id) == 'number' then + local name = GetSpellInfo(id) or "" + local icon = select(3, GetSpellInfo(id)) + icon = icon and "|T"..icon..":0|t" or "" + values[id] = format("%s %s (%s)", icon, name, id) + else + local icon = select(3, GetSpellInfo(id)) + icon = icon and "|T"..icon..":0|t" or "" + values[id] = format("%s %s", icon, id) + end end return values end, @@ -1182,7 +1201,17 @@ function mod:LoadConfig(db) tinsert(sortedKeys, id) end tsort(sortedKeys, function(a, b) - return (GetSpellInfo(a) or "") < (GetSpellInfo(b) or "") + local nameA = GetSpellInfo(a) + local nameB = GetSpellInfo(b) + if not nameA and not nameB then + return a < b + elseif not nameB then + return true + elseif not nameA then + return false + else + return nameA < nameB + end end) return sortedKeys end, @@ -1226,7 +1255,9 @@ function mod:LoadConfig(db) }, } if not next(db['FRIENDLY_PLAYER'].units.target.spellList) then - db['FRIENDLY_PLAYER'].units.target.spellList = CopyTable(core.SpellLists["DEFAULTS"]) + for id, cdTime in pairs(core.SpellLists["DEFAULTS"]) do + db['FRIENDLY_PLAYER'].units.target.spellList[id == 47860 and id or GetSpellInfo(id)] = cdTime + end end if not db['FRIENDLY_PLAYER'].units.player then for _, unitframeType in ipairs({'player', 'focus', 'raid', 'raid40', 'party'}) do @@ -1247,7 +1278,7 @@ local function combatLogEvent(_, ...) local _, eventType, _, sourceName, sourceFlags, _, _, _, spellID = ... if eventType == "SPELL_CAST_SUCCESS" and sourceName then - local cdTime = allSpells[spellID] + local cdTime = allSpells[spellID] or allSpells[GetSpellInfo(spellID)] local isPlayer = band(sourceFlags, COMBATLOG_OBJECT_TYPE_PLAYER) == COMBATLOG_OBJECT_TYPE_PLAYER if cdTime and (isPlayer or band(sourceFlags, COMBATLOG_OBJECT_CONTROL_PLAYER) == COMBATLOG_OBJECT_CONTROL_PLAYER) then local startTime = GetTime() @@ -1274,12 +1305,14 @@ function mod:UpdateCooldowns(playerName, spellID, startTime, endTime, isPlayer) end end end + local name, _, icon = GetSpellInfo(spellID) tinsert(activeCds, { spellID = spellID, + spellName = name, startTime = startTime, endTime = endTime, - icon = select(3, GetSpellInfo(spellID)), + icon = icon, isTrinket = trinkets[spellID] }) self:UpdateFrames(playerName, isPlayer, hash) @@ -1373,7 +1406,7 @@ function mod:AttachCooldowns(frame, cooldowns) local maxShown = db_icons.perRow * db_icons.maxRows for _, cd in ipairs(cooldowns) do - if db_spellList[cd.spellID] then + if db_spellList[cd.spellID] or db_spellList[cd.spellName] then if shown >= maxShown then break end local cdFrame = tracker.cooldowns[shown+1] @@ -1442,9 +1475,11 @@ function mod:AttachCooldowns(frame, cooldowns) end end end + local highlights = highlightedSpells[unitType] cdFrame.endTime = endTime cdFrame.startTime = startTime cdFrame.cooldowns = cooldowns + cdFrame.highlight = highlights[cd.spellID] and highlights[cd.spellID] or highlights[cd.spellName] cdFrame.texture:SetTexture(cd.icon) cdFrame:SetScript("OnUpdate", onUpdates[unitType][frameType]) @@ -1464,7 +1499,6 @@ function mod:AttachCooldowns(frame, cooldowns) end function mod:RepositionIcons(tracker, shown, unitType, frameType) - local highlights = highlightedSpells[unitType] local info = iconPositions[unitType][frameType][shown] local iconPos = info.positions local cooldowns = tracker.cooldowns @@ -1476,8 +1510,8 @@ function mod:RepositionIcons(tracker, shown, unitType, frameType) local position = iconPos[i] cdFrame:Point(position.point, tracker, position.point, position.xOffset, position.yOffset) - local highlight = highlights[cdFrame.spellID] - if highlight and highlight.enabled then + local highlight = cdFrame.highlight + if highlight then cdFrame.shadow:SetOutside(cdFrame, highlight.size, highlight.size) cdFrame.shadow:SetBackdrop({edgeFile = edgeFile, edgeSize = E:Scale(highlight.size)}) cdFrame.shadow:SetBackdropBorderColor(unpack(highlight.color)) @@ -1563,7 +1597,9 @@ function mod:SetupCooldowns(db, visibilityUpdate) for _, unitType in ipairs({"FRIENDLY_PLAYER", "ENEMY_PLAYER"}) do for spellID, info in pairs(db[unitType].highlightedSpells or {}) do - highlightedSpells[unitType][spellID] = info + if info.enabled then + highlightedSpells[unitType][spellID] = info + end end end twipe(framelist)