/
AddonName, AddonEnv = ...; |
local ReadySpells = AddonEnv.ReadySpells; |
local LIBSN2SID = AddonEnv.LIBSN2SID; |
local SID = AddonEnv.SID; -- Spell IDs |
local LSN = AddonEnv.LSN; -- Localised Spell Names |
local LIBSN2SIDP = AddonEnv.LIBSN2SIDP; |
local SIDP = AddonEnv.SIDP; -- Spell IDs |
local LSNP = AddonEnv.LSNP; -- Localised Spell Names |
local SID = LIBSN2SID.SID; -- Spell IDs |
local LSN = LIBSN2SID.LSN; -- Localised Spell Names |
-- NB: 'failcode2' was used in several instances but was NEVER defined anywhere! |
-- Thus I replaced all occurrences of 'failcode2' with 'failCode2',which was |
local ReadySpells = AddonEnv.ReadySpells; |
local LIBSN2SID = AddonEnv.LIBSN2SID; |
local SID = AddonEnv.SID; -- Spell IDs |
local LSN = AddonEnv.LSN; -- Localised Spell Names |
local LIBSN2SIDP = AddonEnv.LIBSN2SIDP; |
local SIDP = AddonEnv.SIDP; -- Spell IDs |
local LSNP = AddonEnv.LSNP; -- Localised Spell Names |
local SID = LIBSN2SID.SID; -- Spell IDs |
local LSN = LIBSN2SID.LSN; -- Localised Spell Names |
-------------------- |
-- Declare the slash-command |
SLASH_READYSPELLS = '/rs'; |
-- Create local aliases for LibSpellName2SID and LibSpellName2SID-Passives |
-- Create local aliases for LibSpellName2SID |
local LIBSN2SID = LibStub:GetLibrary("LibSpellName2SID"); |
local SID = LIBSN2SID.SID; -- Spell IDs |
local LSN = LIBSN2SID.LSN; -- Localised Spell Names |
local LIBSN2SIDP = LibStub:GetLibrary("LibSpellName2SID-Passives"); |
local SIDP = LIBSN2SIDP.SID; -- Spell IDs |
local LSNP = LIBSN2SIDP.LSN; -- Localised Spell Names |
-- Export LibSpellName2SID and LibSpellName2SID-Passives tokens to ReadySpell's environment |
-- Export LibSpellName2SID tokens to ReadySpell's environment |
AddonEnv.LIBSN2SID = LIBSN2SID; |
AddonEnv.SID = SID; |
AddonEnv.LSN = LSN; |
AddonEnv.LIBSN2SIDP = LIBSN2SIDP; |
AddonEnv.SIDP = SIDP; |
AddonEnv.LSNP = LSNP; |
-- AddonEnv-scope variables and tables; These two used to be set in Core.lua, called from therein. |
-- I've now moved the functions that set them to this file instead. |
AddonEnv.spellList = {}; |
---- Local helper functions, used only in this file ---- |
-------------------------------------------------------- |
-- TODO: This function is currently being used to validate both spells to display and spells to save |
-- into the database; The later will not validate if, for example, they are inactive Talent spells; |
-- This would better be a two-part validation: |
-- - Spells to display now should work as bellow; |
-- - Spells whjch might be activated during a given character session (talent change, spec change |
-- and no auto-switch profiles for that spec, etc) should be validated for storing, but not for |
-- display. |
-- Implementing this will require changes in other parts! |
local function validateSpell(spellname) |
--[[ for k in pairs(spellList)do |
if spellList[k] == spellname then |
return true |
end |
end ]]-- |
spellname = SID[spellname] or spellname; |
if ReadySpells.db.profile.spellList[spellname] == nil then |
-- DBG Start |
-- if spellname then |
-- print(AddonName.. ": did NOT validate (existing) ".. tostring(spellname).. ": ".. tostring(SID[spellname]).. ": ".. tostring(LSN[spellname])); |
-- if LSN[spellname] then |
-- print(AddonName.. ": did NOT validate (existing) ".. LSN[spellname]); |
-- end |
-- DBG End |
return false; |
else |
-- print(AddonName.. ": validated ".. tostring(spellname).. ": ".. tostring(SID[spellname]).. ": ".. tostring(LSN[spellname])); |
-- print(AddonName.. ": validated ".. tostring(LSN[spellname]).. " - ".. tostring(SID[spellname])); |
return true; |
end |
end |
if newlineFoundAt == nil then -- No more spells in the list |
-- The code bellow substitutes a value of 'nil' with a *non-'nil'* empty string, i.e. with "" |
wspellNameFound = strsub(wspellsListString, beginStrFindAt); |
-- if LSN[wspellNameFound] then -- If available, use the _Localised_ Spell Name |
-- wspellNameFound = LSN[wspellNameFound]; |
-- end |
-- wspellNameFound = LSN[wspellNameFound] or wspellNameFound; |
wspellNameFound = SID[wspellNameFound] or wspellNameFound; -- Store as Spell ID |
-- print("aallkkaa: wspellNameFound with newlineFoundAt == nil: ".. wspellNameFound); |
if validateSpell(wspellNameFound) then -- Spell in the list of (available?) spells? |
break |
else |
wspellNameFound = strsub(wspellsListString, beginStrFindAt, newlineFoundAt -1); |
-- if LSN[wspellNameFound] then -- If available, use the _Localised_ Spell Name |
-- wspellNameFound = LSN[wspellNameFound]; |
-- end |
wspellNameFound = SID[wspellNameFound] or wspellNameFound; |
-- print("aallkkaa: wspellNameFound with newlineFoundAt NOT nil: ".. wspellNameFound); |
if validateSpell(wspellNameFound) then |
-- condLine1stPart, condLine2ndPart = stringToTable(strsub(condListString, beginStrFindAt, newlineFoundAt), beginStrFindAt); |
condLine1stPart, condLine2ndPart = stringToTable(strsub(condListString, beginStrFindAt, newlineFoundAt)); |
condLine1stPart = SID[condLine1stPart] or condLine1stPart; |
-- The function we're in, setDbBuffCondition(...), is called to set whether |
-- "spellToHide = stanceToHde" or "spellToCast = buffOrDebuffTo". Given that stance |
-- numbers are only 1 digit long and spell IDs (incl. auras) are at least 3 digits |
-- long, we can safely pass the stance numbers through our spell databases and let |
-- them fall back to their original value |
condLine2ndPart = SIDP[condLine2ndPart] or SID[condLine2ndPart] or condLine2ndPart; |
addToTable(dadb, condLine1stPart, trim(condLine2ndPart)); |
newlineFoundAt = strfind(condListString, "\n", beginStrFindAt); |
else |
-- condLine1stPart, condLine2ndPart = stringToTable(strsub(condListString, beginStrFindAt, newlineFoundAt), beginStrFindAt); |
condLine1stPart, condLine2ndPart = stringToTable(strsub(condListString, beginStrFindAt, newlineFoundAt)); |
condLine1stPart = SID[condLine1stPart] or condLine1stPart; |
condLine2ndPart = SIDP[condLine2ndPart] or SID[condLine2ndPart] or condLine2ndPart; |
addToTable(dadb, condLine1stPart, trim(condLine2ndPart)); |
beginStrFindAt = newlineFoundAt + 1; |
newlineFoundAt = strfind(condListString, "\n", beginStrFindAt); |
if dadb ~= nil then -- NB: The condition here is properly set, as opposed to what happens in getDBValue() |
for j, k in pairs(dadb) do |
j = LSN[j] or j; |
k = LSNP[k] or LSN[k] or k; |
if dString ~= nil then |
dString = dString .. j .. " = " ..k .. "\n"; |
else |
-- local sType; -- As returned by GetSpellBookItemInfo(...): "SPELL", "PETACTION", "FUTURESPELL", "FLYOUT" |
-- local spNum; -- According to wowpedia, this would be the spellID returned by GetSpellBookItemInfo BUT |
-- my experience in LibSpellName2SID-Populator tells me it's something else (or bugged); |
-- therefore, as I'm not sure what it really is, we'll leave this var have its old name. |
-- therefore, as I'm not sure what it really is, we'll leave this var have it's old name. |
local sType, spNum = GetSpellBookItemInfo(spellName); |
if sType == nil then |
-- print(AddonName.. ": SpellName NOT : " .. spellName); |
-- ReadySpells:RefreshConfig() |
ReadySpells.db.profile.reset = false; |
else |
ReadySpells.db.profile.reset = true; -- added by aallkkaa |
end |
end, |
}, -- redo |
knownFilter = { -- DONE: Correctly displays only spells in the Spellbook if |
-- enabled. I still don't know what the "Blizzard Bug" is. |
-- TODO: Ask benots4 ! |
knownFilter = { -- TODO: Check whether there is, in the current version, |
-- any point to this. I believe this is the default and only |
-- implemented mode. ON actually, even if the desc of this |
-- option here says it's OFF by default, as it actually does |
-- nothing at all here, and displayed spells are ALWAYS checked |
-- against the list of known ("available") spells. |
name = 'Known Filter', |
desc = 'Only list Known Spells \n default off for Blizzard Bug', |
type = 'toggle', |
end |
end, |
}, -- knownFilter |
dpsfeatures = { -- There is stuff done on this subject, at the bottom of |
-- Core.lua. TODO: Check it out! |
dpsfeatures = { -- There is something done on this |
-- subject, at the bottom of Core.lua. |
-- TODO: Check it out! |
name = 'DPS Features', |
desc = 'In development DPS features', |
type = 'toggle', |
local v , dString |
-- if spellList ~= nil then |
for k, v in pairs(ReadySpells.db.profile.spellList) do |
-- for k in ipairs(ReadySpells.db.profile.spellList) do |
-- LSN[k] gets the localized spell name of the saved spell, |
-- regardless of what language the spell was saved in, or |
-- whether it's even a spell name or rather a spell ID. |
-- The values of k here were saved as SID[k] by function |
-- getSpellList(). |
-- 'v' is the order index in the spell list and was already |
-- being correctly handled, namely it's sorted in set func. |
k = LSN[k] or k; |
if dString ~= nil then |
dString = dString .. k .. "\n" |
-- dString = dString .. k .. "\n"; |
dString = dString .. k .. "\n" |
else |
-- dString = k .. "\n"; |
dString = k .. "\n"; |
end |
end |
end, |
set = function() |
-- print(AddonName.. ": In spelllist->set()"); |
ReadySpells:getSpellList(); |
ReadySpells.getSpellList(); |
end, |
}, -- spelllist |
}, -- args |
end |
end, |
set = function(_, f) |
setWatchSpells(i, f); |
setWatchSpells(i, f) |
end, |
} -- ReadySpells.options.args.spellsels.args["spellcell"..i] |
end -- for i = 1, 9 do |
}, |
hidespells ={ -- For Shaman, this can be used with "Ghost Wolf = 1" |
-- to hide it while already in Ghost Wolf; otherwise |
-- the icon is shown, with a cooldown begative number! |
-- the icon is shown, with a cooldown number! |
name = 'Hide Spells', |
type = 'group', |
-- inline = true, |
get = function() |
-- local v , dString; -- 'v' is not used in this function |
local dString; |
-- if ReadySpells.db.profile.hideNForm == nil then |
-- elseif ReadySpells.db.profile.hideNForm ~= nil then |
if ReadySpells.db.profile.hideNForm ~= nil then |
for j, k in pairs(ReadySpells.db.profile.hideNForm) do |
-- LSN[j] == localized name of spell to hide; k == form num |
if ReadySpells.db.profile.hideNForm == nil then |
ReadySpells.db.profile.hideNForm = {} |
end |
-- TODO: Similar to getDbPair bellow (see note in spellselfbuff) |
setDbBuffCondition(ReadySpells.db.profile.hideNForm, f) |
end, |
}, -- hideSpell |
width = 'full', |
get = function() |
if ReadySpells.db.profile.selfBuffStacks ~= nil then |
-- DONE: getDBPair is set to fetch the localized name of "Self |
-- Buff Spell" (and the two others bellow) via LSN[spell]; and |
-- "Buff" is fetched via "LSNP[spell] or LSN[spell]; |
-- TODO: LibSpellName2SID-Passives should contain all possible |
-- Player cast buffs and debuffs (I think), but NOT the NPC |
-- ones, which the player might want to track. |
-- IIRC there is a Babble library for Boss spells (likely none |
-- for all NPC spells...), so we might want to use both libs |
-- with a fallback to untranslated (NPC) abilities. |
-- TODO: Currently, getDBPair is set to fetch the localized |
-- name of "Self Buff Spell" (and the two others bellow) via |
-- LSN[spell], but gets the unchanged "Buff"; Implement the |
-- getting the localized "Buff" (NB: LibSpellName2SID-Passives |
-- should contains all possible Player cast buffs and debuffs |
-- but NOT the NPC ones, which the player might want to track. |
-- IIRC there is a BabbleFish library for Boss spells (likely |
-- not for all NPC spells...), so we might want to use both |
-- libs with a fallback to untranslated (NPC) abilities. |
return getDbPair(ReadySpells.db.profile.selfBuffStacks); |
end |
end, |
if ReadySpells.db.profile.selfBuffStacks == nil then |
ReadySpells.db.profile.selfBuffStacks = {}; |
end |
-- TODO: Similar to getDbPair above but using SID instead of LSN |
setDbBuffCondition(ReadySpells.db.profile.selfBuffStacks, f); |
end, |
}, -- spellselfbuff |
if ReadySpells.db.profile.buffStacks == nil then |
ReadySpells.db.profile.buffStacks = {} |
end |
-- TODO: See TODO note on spellselfbuff above |
setDbBuffCondition(ReadySpells.db.profile.buffStacks,f) |
end, |
}, -- spellbuff |
width = 'full', |
get = function() |
if ReadySpells.db.profile.debuffStacks ~= nil then |
-- TODO: See TODO note on spellselfbuff above |
return getDbPair(ReadySpells.db.profile.debuffStacks); |
end |
end, |
if ReadySpells.db.profile.debuffStacks == nil then |
ReadySpells.db.profile.debuffStacks = {} |
end |
-- TODO: See TODO note on spellselfbuff above |
setDbBuffCondition(ReadySpells.db.profile.debuffStacks, f); |
end, |
}, -- spelldebuff |