Skip to content

Commit

Permalink
Allow using name for custom spells (known only)
Browse files Browse the repository at this point in the history
  • Loading branch information
nebularg committed Jul 27, 2018
1 parent 6ebe889 commit ca79392
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
21 changes: 11 additions & 10 deletions CommonAuras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions Locales.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit ca79392

Please sign in to comment.