From ca79392cac2978b51c197f605f42161ad5f8c3e6 Mon Sep 17 00:00:00 2001 From: Kyle Buller Date: Fri, 27 Jul 2018 16:53:48 -0500 Subject: [PATCH] Allow using name for custom spells (known only) --- CommonAuras.lua | 21 +++++++++++---------- Locales.lua | 10 ++++++++++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/CommonAuras.lua b/CommonAuras.lua index 5fcfcc0..bbeeee2 100644 --- a/CommonAuras.lua +++ b/CommonAuras.lua @@ -310,31 +310,32 @@ local function GetOptions() add = { type = "input", name = L.addSpell, + desc = L.addSpellDesc, get = false, set = function(info, value) - value = tonumber(value) - mod.db.profile.custom[value] = { + local _, _, _, _, _, _, spellId = GetSpellInfo(value) + mod.db.profile.custom[spellId] = { event = "SPELL_CAST_SUCCESS", format = "used_cast", duration = 0, } - mod.db.profile[value] = 0 + mod.db.profile[spellId] = 0 end, validate = function(info, value) - value = tonumber(value) - if not value or not GetSpellInfo(value) then + local _, _, _, _, _, _, spellId = GetSpellInfo(value) + if not spellId then return ("%s: %s"):format(L.commonAuras, L.customErrorInvalid) - elseif mod.db.profile[value] then + elseif mod.db.profile[spellId] then return ("%s: %s"):format(L.commonAuras, L.customErrorExists) end return true end, confirm = function(info, value) - local spell, _, texture = GetSpellInfo(value) + local spell, _, texture, _, _, _, spellId = GetSpellInfo(value) if not spell then return false end - local desc = GetSpellDescription(value) or "" + local desc = GetSpellDescription(spellId) or "" if desc ~= "" then desc = "\n" .. desc:gsub("%%", "%%%%") end - return ("%s\n\n|T%d:0|t|cffffd200%s|r%s"):format(L.customConfirmAdd, texture, spell, desc) + return ("%s\n\n|T%d:0|t|cffffd200%s|r (%d)%s"):format(L.customConfirmAdd, texture, spell, spellId, desc) end, order = 1, }, @@ -388,7 +389,7 @@ local function GetOptions() args = { master = { type = "toggle", - name = ("|cfffed000%s|r"):format((GetSpellInfo(key))), + name = ("|cfffed000%s|r (%d)"):format((GetSpellInfo(key)), key), desc = GetSpellDescription(key), descStyle = "inline", image = GetSpellTexture(key), get = masterGet, diff --git a/Locales.lua b/Locales.lua index 4ca8b50..43e5a70 100644 --- a/Locales.lua +++ b/Locales.lua @@ -16,6 +16,7 @@ L.customErrorInvalid = "Invalid spell id!" L.customErrorExists = "Spell already exists!" L.customConfirmAdd = "Add spell?" L.addSpell = "Add spell by id" +L.addSpellDesc = "You can also add spells you currently know by name, but it is always best to use the id from logs." L.event = "Event" L.duration = "Bar duration" L.textFormat = "Text format" @@ -61,6 +62,7 @@ if locale == "deDE" then -- L.customErrorExists = "Spell already exists!" -- L.customConfirmAdd = "Add spell?" -- L.addSpell = "Add spell by id" + -- L.addSpellDesc = "You can also add spells you currently know by name, but it is always best to use the id from logs." -- L.event = "Event" -- L.duration = "Bar duration" -- L.textFormat = "Text format" @@ -100,6 +102,7 @@ elseif locale == "esES" or locale == "esMX" then -- L.customErrorExists = "Spell already exists!" -- L.customConfirmAdd = "Add spell?" -- L.addSpell = "Add spell by id" + -- L.addSpellDesc = "You can also add spells you currently know by name, but it is always best to use the id from logs." -- L.event = "Event" -- L.duration = "Bar duration" -- L.textFormat = "Text format" @@ -139,6 +142,7 @@ elseif locale == "frFR" then -- L.customErrorExists = "Spell already exists!" -- L.customConfirmAdd = "Add spell?" -- L.addSpell = "Add spell by id" + -- L.addSpellDesc = "You can also add spells you currently know by name, but it is always best to use the id from logs." -- L.event = "Event" -- L.duration = "Bar duration" -- L.textFormat = "Text format" @@ -178,6 +182,7 @@ elseif locale == "itIT" then -- L.customErrorExists = "Spell already exists!" -- L.customConfirmAdd = "Add spell?" -- L.addSpell = "Add spell by id" + -- L.addSpellDesc = "You can also add spells you currently know by name, but it is always best to use the id from logs." -- L.event = "Event" -- L.duration = "Bar duration" -- L.textFormat = "Text format" @@ -217,6 +222,7 @@ elseif locale == "koKR" then -- L.customErrorExists = "Spell already exists!" -- L.customConfirmAdd = "Add spell?" -- L.addSpell = "Add spell by id" + -- L.addSpellDesc = "You can also add spells you currently know by name, but it is always best to use the id from logs." -- L.event = "Event" -- L.duration = "Bar duration" -- L.textFormat = "Text format" @@ -256,6 +262,7 @@ elseif locale == "ptBR" then L.customErrorExists = "Feitiço já existe!" L.customConfirmAdd = "Adicionar feitiço?" L.addSpell = "Adicionar feitiço por id" + -- L.addSpellDesc = "You can also add spells you currently know by name, but it is always best to use the id from logs." L.event = "Evento" L.duration = "Duração da Barra" L.textFormat = "Formato do texto" @@ -294,6 +301,7 @@ elseif locale == "ruRU" then -- L.customErrorInvalid = "Invalid spell id!" -- L.customErrorExists = "Spell already exists!" -- L.customConfirmAdd = "Add spell?" + -- L.addSpellDesc = "You can also add spells you currently know by name, but it is always best to use the id from logs." -- L.addSpell = "Add spell by id" -- L.event = "Event" -- L.duration = "Bar duration" @@ -333,6 +341,7 @@ elseif locale == "zhCN" then -- L.customErrorInvalid = "Invalid spell id!" -- L.customErrorExists = "Spell already exists!" -- L.customConfirmAdd = "Add spell?" + -- L.addSpellDesc = "You can also add spells you currently know by name, but it is always best to use the id from logs." -- L.addSpell = "Add spell by id" -- L.event = "Event" -- L.duration = "Bar duration" @@ -373,6 +382,7 @@ elseif locale == "zhTW" then L.customErrorExists = "法術已經存在!" L.customConfirmAdd = "確定要添加法術?" -- L.addSpell = "Add spell by id" + -- L.addSpellDesc = "You can also add spells you currently know by name, but it is always best to use the id from logs." -- L.event = "Event" -- L.duration = "Bar duration" -- L.textFormat = "Text format"