Expose way to trace spellcasts by spell ID or spell name.
Johnny C. Lam [08-10-13 - 18:40]
Expose way to trace spellcasts by spell ID or spell name.
git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1002 d5049fe3-3747-40f7-a4b5-f36d6801af5f
diff --git a/OvaleFuture.lua b/OvaleFuture.lua
index f62a83c..c03415c 100644
--- a/OvaleFuture.lua
+++ b/OvaleFuture.lua
@@ -71,15 +71,19 @@ local OVALE_CLEU_SPELLCAST_RESULTS = {
OvaleFuture.counter = {}
-- Most recent latency (time between UNIT_SPELLCAST_SENT and UNIT_SPELLCAST_SUCCEEDED events).
OvaleFuture.latency = 0
--- Debugging: spell ID to trace
-OvaleFuture.traceSpellId = nil
+-- Debugging: spells to trace
+OvaleFuture.traceSpellList = nil
--</public-static-properties>
--<private-static-methods>
local function TracePrintf(spellId, ...)
local self = OvaleFuture
- if self.traceSpellId then
- if (self.traceSpellId == spellId) or (type(spellId) == "string" and OvaleData:GetSpellName(self.traceSpellId) == spellId) then
+ if self.traceSpellList then
+ local name = spellId
+ if type(spellId) == "number" then
+ name = OvaleData:GetSpellName(spellId)
+ end
+ if self.traceSpellList[spellId] or self.traceSpellList[name] then
Ovale:FormatPrint(...)
end
end
diff --git a/OvaleOptions.lua b/OvaleOptions.lua
index ed83817..9be40ee 100644
--- a/OvaleOptions.lua
+++ b/OvaleOptions.lua
@@ -22,6 +22,7 @@ local OvaleScripts = Ovale.OvaleScripts
local strgmatch = string.gmatch
local strgsub = string.gsub
local tostring = tostring
+local API_GetSpellInfo = GetSpellInfo
--</private-static-properties>
--<public-static-properties>
@@ -405,11 +406,64 @@ local self_options =
{
trace =
{
- name = "Trace",
+ order = 10,
type = "execute",
name = "Trace next frame",
- func = function()
- Ovale.trace = true
+ func = function() Ovale.trace = true end,
+ },
+ traceSpellId =
+ {
+ order = 20,
+ type = "input",
+ dialogControl = "Aura_EditBox",
+ name = "Trace spellcast",
+ desc = "Names or spell IDs of spellcasts to watch, separated by semicolons.",
+ get = function(info)
+ local OvaleFuture = Ovale.OvaleFuture
+ if OvaleFuture then
+ local t = OvaleFuture.traceSpellList or {}
+ local s = ""
+ for k, v in pairs(t) do
+ if type(v) == "boolean" then
+ if string.len(s) == 0 then
+ s = k
+ else
+ s = s .. "; " .. k
+ end
+ end
+ end
+ return s
+ else
+ return ""
+ end
+ end,
+ set = function(info, value)
+ local OvaleFuture = Ovale.OvaleFuture
+ if OvaleFuture then
+ local t = {}
+ for s in strgmatch(value, "[^;]+") do
+ -- strip leading and trailing whitespace
+ s = strgsub(s, "^%s*", "")
+ s = strgsub(s, "%s*$", "")
+ if string.len(s) > 0 then
+ local v = tonumber(s)
+ if v then
+ s = API_GetSpellInfo(v)
+ if s then
+ t[v] = true
+ t[s] = v
+ end
+ else
+ t[s] = true
+ end
+ end
+ end
+ if next(t) then
+ OvaleFuture.traceSpellList = t
+ else
+ OvaleFuture.traceSpellList = nil
+ end
+ end
end,
},
},