add latest TBC version of !Compatibility and !DebugTools

This commit is contained in:
Pinya
2017-12-14 20:10:16 +03:00
parent c7007b9186
commit 0be2449e90
19 changed files with 4858 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
## Interface: 20400
## Title: !Compatibility
## Notes: Compatibility functions for TBC
## Version: 1.0
errorHandler.lua
api\api.xml
slashCommands.lua
+6
View File
@@ -0,0 +1,6 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="luaAPI.lua"/>
<Include file="..\libs\libs.xml"/>
<Script file="widgetAPI.lua"/>
<Script file="wowAPI.lua"/>
</Ui>
+86
View File
@@ -0,0 +1,86 @@
--Cache global variables
local error = error
local geterrorhandler = geterrorhandler
local pairs = pairs
local pcall = pcall
local securecall = securecall
local select = select
local tostring = tostring
local type = type
local unpack = unpack
function table.wipe(t)
assert(type(t) == "table", format("bad argument #1 to 'wipe' (table expected, got %s)", t and type(t) or "no value"))
for k in pairs(t) do
t[k] = nil
end
return t
end
wipe = table.wipe
local LOCAL_ToStringAllTemp = {}
function tostringall(...)
local n = select('#', ...)
-- Simple versions for common argument counts
if (n == 1) then
return tostring(...)
elseif (n == 2) then
local a, b = ...
return tostring(a), tostring(b)
elseif (n == 3) then
local a, b, c = ...
return tostring(a), tostring(b), tostring(c)
elseif (n == 0) then
return
end
local needfix
for i = 1, n do
local v = select(i, ...)
if (type(v) ~= "string") then
needfix = i
break
end
end
if (not needfix) then return ... end
wipe(LOCAL_ToStringAllTemp)
for i = 1, needfix - 1 do
LOCAL_ToStringAllTemp[i] = select(i, ...)
end
for i = needfix, n do
LOCAL_ToStringAllTemp[i] = tostring(select(i, ...))
end
return unpack(LOCAL_ToStringAllTemp)
end
local LOCAL_PrintHandler = function(...)
DEFAULT_CHAT_FRAME:AddMessage(strjoin(" ", tostringall(...)))
end
function setprinthandler(func)
if (type(func) ~= "function") then
error("Invalid print handler")
else
LOCAL_PrintHandler = func
end
end
function getprinthandler() return LOCAL_PrintHandler end
local function print_inner(...)
local ok, err = pcall(LOCAL_PrintHandler, ...)
if (not ok) then
local func = geterrorhandler()
func(err)
end
end
function print(...)
securecall(pcall, print_inner, ...)
end
SLASH_PRINT1 = "/print"
SlashCmdList["PRINT"] = print
+51
View File
@@ -0,0 +1,51 @@
--Cache global variables
local assert = assert
local format = string.format
local tonumber = tonumber
local type = type
local function GetSize(frame)
return frame:GetWidth(), frame:GetHeight()
end
local function SetSize(frame, width, height)
width, height = tonumber(width), tonumber(height)
assert(type(width) == "number" or type(width) == "string", format("Usage: %s:SetSize(width, height)", frame.GetName and frame:GetName() or tostring(frame)))
frame:SetWidth(width)
frame:SetHeight(type(height) == "number" and height or width)
end
local function HookScript2(frame, scriptType, handler)
assert((type(scriptType) == "string" or type(scriptType) == "number") and type(handler) == "function", format("Usage: %s:HookScript2(\"type\", function)", frame.GetName and frame:GetName() or tostring(frame)))
if frame:GetScript(scriptType) then
frame:HookScript(scriptType, handler)
else
frame:SetScript(scriptType, handler)
end
end
local function addapi(object)
local mt = getmetatable(object).__index
if not object.GetSize then mt.GetSize = GetSize end
if not object.SetSize then mt.SetSize = SetSize end
if not object.HookScript2 then mt.HookScript2 = HookScript2 end
end
local handled = {["Frame"] = true}
local object = CreateFrame("Frame")
addapi(object)
addapi(object:CreateTexture())
addapi(object:CreateFontString())
object = EnumerateFrames()
while object do
if not handled[object:GetObjectType()] then
addapi(object)
handled[object:GetObjectType()] = true
end
object = EnumerateFrames(object)
end
+313
View File
@@ -0,0 +1,313 @@
--Cache global variables
local assert = assert
local date = date
local pairs = pairs
local tonumber = tonumber
local type = type
local format, gsub, lower, match, upper = string.format, string.gsub, string.lower, string.match, string.upper
--WoW API
local GetCurrentDungeonDifficulty = GetCurrentDungeonDifficulty
local GetQuestGreenRange = GetQuestGreenRange
local GetRealZoneText = GetRealZoneText
local IsInInstance = IsInInstance
local UnitBuff = UnitBuff
local UnitDebuff = UnitDebuff
local UnitLevel = UnitLevel
--WoW Variables
local DUNGEON_DIFFICULTY1 = DUNGEON_DIFFICULTY1
local DUNGEON_DIFFICULTY2 = DUNGEON_DIFFICULTY2
local TIMEMANAGER_AM = TIMEMANAGER_AM
local TIMEMANAGER_PM = TIMEMANAGER_PM
--Libs
local LBC = LibStub("LibBabble-Class-3.0"):GetLookupTable()
local LBZ = LibStub("LibBabble-Zone-3.0"):GetLookupTable()
CLASS_SORT_ORDER = {
"WARRIOR",
"PALADIN",
"PRIEST",
"SHAMAN",
"DRUID",
"ROGUE",
"MAGE",
"WARLOCK",
"HUNTER"
}
MAX_CLASSES = #CLASS_SORT_ORDER
LOCALIZED_CLASS_NAMES_MALE = {}
LOCALIZED_CLASS_NAMES_FEMALE = {}
CLASS_ICON_TCOORDS = {
["WARRIOR"] = {0, 0.25, 0, 0.25},
["MAGE"] = {0.25, 0.49609375, 0, 0.25},
["ROGUE"] = {0.49609375, 0.7421875, 0, 0.25},
["DRUID"] = {0.7421875, 0.98828125, 0, 0.25},
["HUNTER"] = {0, 0.25, 0.25, 0.5},
["SHAMAN"] = {0.25, 0.49609375, 0.25, 0.5},
["PRIEST"] = {0.49609375, 0.7421875, 0.25, 0.5},
["WARLOCK"] = {0.7421875, 0.98828125, 0.25, 0.5},
["PALADIN"] = {0, 0.25, 0.5, 0.75}
}
QuestDifficultyColors = {
["impossible"] = {r = 1.00, g = 0.10, b = 0.10},
["verydifficult"] = {r = 1.00, g = 0.50, b = 0.25},
["difficult"] = {r = 1.00, g = 1.00, b = 0.00},
["standard"] = {r = 0.25, g = 0.75, b = 0.25},
["trivial"] = {r = 0.50, g = 0.50, b = 0.50},
["header"] = {r = 0.70, g = 0.70, b = 0.70}
}
function UnitAura(unit, i, filter)
assert((type(unit) == "string" or type(unit) == "number") and (type(i) == "string" or type(i) == "number"), "Usage: UnitAura(\"unit\", index [, filter])")
if not filter or match(filter, "(HELPFUL)") then
local name, rank, aura, count, duration, maxDuration = UnitBuff(unit, i, filter)
return name, rank, aura, count, nil, duration or 0, maxDuration or 0
else
local name, rank, aura, count, dType, duration, maxDuration = UnitDebuff(unit, i, filter)
return name, rank, aura, count, dType, duration or 0, maxDuration or 0
end
end
function BetterDate(formatString, timeVal)
local dateTable = date("*t", timeVal)
local amString = (dateTable.hour >= 12) and TIMEMANAGER_PM or TIMEMANAGER_AM
--First, we'll replace %p with the appropriate AM or PM.
formatString = gsub(formatString, "^%%p", amString) --Replaces %p at the beginning of the string with the am/pm token
formatString = gsub(formatString, "([^%%])%%p", "%1"..amString) -- Replaces %p anywhere else in the string, but doesn't replace %%p (since the first % escapes the second)
return date(formatString, timeVal)
end
function GetQuestDifficultyColor(level)
local levelDiff = level - UnitLevel("player")
if levelDiff >= 5 then
return QuestDifficultyColors["impossible"]
elseif levelDiff >= 3 then
return QuestDifficultyColors["verydifficult"]
elseif levelDiff >= -2 then
return QuestDifficultyColors["difficult"]
elseif -levelDiff <= GetQuestGreenRange() then
return QuestDifficultyColors["standard"]
else
return QuestDifficultyColors["trivial"]
end
end
function FillLocalizedClassList(tab, female)
assert(type(tab) == "table", "Usage: FillLocalizedClassList(classTable[, isFemale])")
for _, engClass in ipairs(CLASS_SORT_ORDER) do
if female then
tab[engClass] = LBC[engClass]
else
tab[engClass] = LBC[engClass:lower():gsub("^%l", upper)]
end
end
return true
end
FillLocalizedClassList(LOCALIZED_CLASS_NAMES_MALE)
FillLocalizedClassList(LOCALIZED_CLASS_NAMES_FEMALE, true)
local zoneInfo = {
-- Battlegrounds
[LBZ["Warsong Gulch"]] = {mapID = 443, maxPlayers = 10},
[LBZ["Arathi Basin"]] = {mapID = 461, maxPlayers = 15},
[LBZ["Alterac Valley"]] = {mapID = 401, maxPlayers = 40},
-- TBC
[LBZ["Eye of the Storm"]] = {mapID = 566, maxPlayers = 15},
-- Raids
[LBZ["Zul'Gurub"]] = {mapID = 309, maxPlayers = 20},
[LBZ["Onyxia's Lair"]] = {mapID = 249, maxPlayers = 40},
[LBZ["Molten Core"]] = {mapID = 409, maxPlayers = 40},
[LBZ["Ruins of Ahn'Qiraj"]] = {mapID = 509, maxPlayers = 20},
[LBZ["Temple of Ahn'Qiraj"]] = {mapID = 531, maxPlayers = 40},
[LBZ["Blackwing Lair"]] = {mapID = 469, maxPlayers = 40},
-- [LBZ["Naxxramas"]] = {mapID = 533, maxPlayers = 40},
-- TBC
[LBZ["Karazhan"]] = {mapID = 532, maxPlayers = 10},
[LBZ["Gruul's Lair"]] = {mapID = 565, maxPlayers = 25},
[LBZ["Magtheridon's Lair"]] = {mapID = 544, maxPlayers = 25},
[LBZ["Zul'Aman"]] = {mapID = 568, maxPlayers = 10},
[LBZ["Serpentshrine Cavern"]] = {mapID = 548, maxPlayers = 25},
[LBZ["The Eye"]] = {mapID = 550, maxPlayers = 25},
[LBZ["Hyjal Summit"]] = {mapID = 534, maxPlayers = 25},
[LBZ["Black Temple"]] = {mapID = 564, maxPlayers = 25},
[LBZ["Sunwell Plateau"]] = {mapID = 580, maxPlayers = 25},
}
local mapByID = {}
for mapName in pairs(zoneInfo) do
mapByID[zoneInfo[mapName].mapID] = mapName
end
local function GetMaxPlayersByType(instanceType, zoneName)
if instanceType == "none" then
return 40
elseif instanceType == "party" then
return 5
elseif instanceType == "arena" then
return 5
elseif zoneName ~= "" and zoneInfo[zoneName] then
if instanceType == "pvp" then
return zoneInfo[zoneName].maxPlayers
elseif instanceType == "raid" then
return zoneInfo[zoneName].maxPlayers
end
else
return 0
end
end
function GetInstanceInfo()
local inInstance, instanceType = IsInInstance()
if not inInstance then return end
local name = GetRealZoneText()
local difficulty = GetCurrentDungeonDifficulty()
local difficultyName = difficulty == 1 and DUNGEON_DIFFICULTY1 or DUNGEON_DIFFICULTY2
local maxPlayers = GetMaxPlayersByType(instanceType, name)
difficultyName = format("%d %s", maxPlayers, difficultyName)
return name, instanceType, difficulty, difficultyName, maxPlayers
end
function GetCurrentMapAreaID()
if not IsInInstance() then return end
local zoneName = GetRealZoneText()
if zoneName ~= "" and zoneInfo[zoneName] then
return zoneInfo[zoneName].mapID
else
return 0
end
end
function GetMapNameByID(id)
assert(type(id) == "string" or type(id) == "number", format("Bad argument #1 to \"GetMapNameByID\" (number expected, got %s)", id and type(id) or "no value"))
return mapByID[tonumber(id)]
end
local arrow
function GetPlayerFacing()
if not arrow then
local obj = Minimap
for i = 1, obj:GetNumChildren() do
local child = select(i, obj:GetChildren())
if child and child.GetModel and child:GetModel() == "interface\\minimap\\minimaparrow.m2" then
arrow = child
break
end
end
end
return arrow and arrow:GetFacing()
end
function ToggleFrame(frame)
if frame:IsShown() then
HideUIPanel(frame)
else
ShowUIPanel(frame)
end
end
local function OnOrientationChanged(self, orientation)
self.texturePointer.verticalOrientation = orientation == "VERTICAL"
if self.texturePointer.verticalOrientation then
self.texturePointer:SetPoint("BOTTOMLEFT", self)
else
self.texturePointer:SetPoint("LEFT", self)
end
end
local function OnSizeChanged(self, width, height)
self.texturePointer.width = width
self.texturePointer.height = height
self.texturePointer:SetWidth(width)
self.texturePointer:SetHeight(height)
end
local function OnValueChanged(self, value)
local _, max = self:GetMinMaxValues()
if self.texturePointer.verticalOrientation then
self.texturePointer:SetHeight(self.texturePointer.height * (value / max))
else
self.texturePointer:SetWidth(self.texturePointer.width * (value / max))
end
end
function CreateStatusBarTexturePointer(statusbar)
assert(type(statusbar) == "table", format("Bad argument #1 to \"CreateStatusBarTexturePointer\" (table expected, got %s)", statusbar and type(statusbar) or "no value"))
assert(statusbar.GetObjectType and statusbar:GetObjectType() == "StatusBar", "Bad argument #1 to \"CreateStatusBarTexturePointer\" (statusbar object expected)")
local f = statusbar:CreateTexture()
f.width = statusbar:GetWidth()
f.height = statusbar:GetHeight()
f.vertical = statusbar:GetOrientation() == "VERTICAL"
f:SetWidth(f.width)
f:SetHeight(f.height)
if f.verticalOrientation then
f:SetPoint("BOTTOMLEFT", statusbar)
else
f:SetPoint("LEFT", statusbar)
end
statusbar.texturePointer = f
statusbar:SetScript("OnSizeChanged", OnSizeChanged)
statusbar:SetScript("OnValueChanged", OnValueChanged)
hooksecurefunc(statusbar, "SetOrientation", OnOrientationChanged)
return f
end
local threatColors = {
[0] = {0.69, 0.69, 0.69},
[1] = {1, 1, 0.47},
[2] = {1, 0.6, 0},
[3] = {1, 0, 0}
}
function GetThreatStatusColor(statusIndex)
if not (type(statusIndex) == "number" and statusIndex >= 0 and statusIndex < 4) then
statusIndex = 0
end
return threatColors[statusIndex][1], threatColors[statusIndex][2], threatColors[statusIndex][3]
end
function GetThreatStatus(currentThreat, maxThreat)
assert(type(currentThreat) == "number" and type(maxThreat) == "number", "Usage: GetThreatStatus(currentThreat, maxThreat)")
if not maxThreat or maxThreat == 0 then
maxThreat = 0
maxThreat = 1
end
local threatPercent = currentThreat / maxThreat * 100
if threatPercent >= 100 then
return 3, threatPercent
elseif threatPercent < 100 and threatPercent >= 80 then
return 2, threatPercent
elseif threatPercent < 80 and threatPercent >= 50 then
return 1, threatPercent
else
return 0, threatPercent
end
end
+46
View File
@@ -0,0 +1,46 @@
--Cache global variables
local strmatch = strmatch
--WoW API
local GetCVar = GetCVar
local IsAddOnLoaded = IsAddOnLoaded
local LoadAddOn = LoadAddOn
local _ERROR_COUNT = 0
local _ERROR_LIMIT = 1000
function _ERRORMESSAGE_NEW(message)
debuginfo()
LoadAddOn("!DebugTools")
local loaded = IsAddOnLoaded("!DebugTools")
if (GetCVar("scriptErrors") == "1") then
if (not loaded or DEBUG_DEBUGTOOLS) then
ScriptErrors_Message:SetText(message)
ScriptErrors:Show()
if (DEBUG_DEBUGTOOLS) then
ScriptErrorsFrame_OnError(message)
end
else
ScriptErrorsFrame_OnError(message)
end
elseif (loaded) then
ScriptErrorsFrame_OnError(message, true)
end
_ERROR_COUNT = _ERROR_COUNT + 1
if (_ERROR_COUNT == _ERROR_LIMIT) then
StaticPopup_Show("TOO_MANY_LUA_ERRORS")
end
return message
end
seterrorhandler(_ERRORMESSAGE_NEW)
function message(text)
if (not ScriptErrors:IsShown()) then
ScriptErrors_Message:SetText(text)
ScriptErrors:Show()
end
end
+292
View File
@@ -0,0 +1,292 @@
-- LibBabble-3.0 is hereby placed in the Public Domain
-- Credits: ckknight
local LIBBABBLE_MAJOR, LIBBABBLE_MINOR = "LibBabble-3.0", 2
local LibBabble = LibStub:NewLibrary(LIBBABBLE_MAJOR, LIBBABBLE_MINOR)
if not LibBabble then
return
end
local data = LibBabble.data or {}
for k,v in pairs(LibBabble) do
LibBabble[k] = nil
end
LibBabble.data = data
local tablesToDB = {}
for namespace, db in pairs(data) do
for k,v in pairs(db) do
tablesToDB[v] = db
end
end
local function warn(message)
local _, ret = pcall(error, message, 3)
geterrorhandler()(ret)
end
local lookup_mt = { __index = function(self, key)
local db = tablesToDB[self]
local current_key = db.current[key]
if current_key then
self[key] = current_key
return current_key
end
local base_key = db.base[key]
local real_MAJOR_VERSION
for k,v in pairs(data) do
if v == db then
real_MAJOR_VERSION = k
break
end
end
if not real_MAJOR_VERSION then
real_MAJOR_VERSION = LIBBABBLE_MAJOR
end
if base_key then
warn(("%s: Translation %q not found for locale %q"):format(real_MAJOR_VERSION, key, GetLocale()))
rawset(self, key, base_key)
return base_key
end
warn(("%s: Translation %q not found."):format(real_MAJOR_VERSION, key))
rawset(self, key, key)
return key
end }
local function initLookup(module, lookup)
local db = tablesToDB[module]
for k in pairs(lookup) do
lookup[k] = nil
end
setmetatable(lookup, lookup_mt)
tablesToDB[lookup] = db
db.lookup = lookup
return lookup
end
local function initReverse(module, reverse)
local db = tablesToDB[module]
for k in pairs(reverse) do
reverse[k] = nil
end
for k,v in pairs(db.current) do
reverse[v] = k
end
tablesToDB[reverse] = db
db.reverse = reverse
db.reverseIterators = nil
return reverse
end
local prototype = {}
local prototype_mt = {__index = prototype}
--[[---------------------------------------------------------------------------
Notes:
* If you try to access a nonexistent key, it will warn but allow the code to pass through.
Returns:
A lookup table for english to localized words.
Example:
local B = LibStub("LibBabble-Module-3.0") -- where Module is what you want.
local BL = B:GetLookupTable()
assert(BL["Some english word"] == "Some localized word")
DoSomething(BL["Some english word that doesn't exist"]) -- warning!
-----------------------------------------------------------------------------]]
function prototype:GetLookupTable()
local db = tablesToDB[self]
local lookup = db.lookup
if lookup then
return lookup
end
return initLookup(self, {})
end
--[[---------------------------------------------------------------------------
Notes:
* If you try to access a nonexistent key, it will return nil.
Returns:
A lookup table for english to localized words.
Example:
local B = LibStub("LibBabble-Module-3.0") -- where Module is what you want.
local B_has = B:GetUnstrictLookupTable()
assert(B_has["Some english word"] == "Some localized word")
assert(B_has["Some english word that doesn't exist"] == nil)
-----------------------------------------------------------------------------]]
function prototype:GetUnstrictLookupTable()
local db = tablesToDB[self]
return db.current
end
--[[---------------------------------------------------------------------------
Notes:
* If you try to access a nonexistent key, it will return nil.
* This is useful for checking if the base (English) table has a key, even if the localized one does not have it registered.
Returns:
A lookup table for english to localized words.
Example:
local B = LibStub("LibBabble-Module-3.0") -- where Module is what you want.
local B_hasBase = B:GetBaseLookupTable()
assert(B_hasBase["Some english word"] == "Some english word")
assert(B_hasBase["Some english word that doesn't exist"] == nil)
-----------------------------------------------------------------------------]]
function prototype:GetBaseLookupTable()
local db = tablesToDB[self]
return db.base
end
--[[---------------------------------------------------------------------------
Notes:
* If you try to access a nonexistent key, it will return nil.
* This will return only one English word that it maps to, if there are more than one to check, see :GetReverseIterator("word")
Returns:
A lookup table for localized to english words.
Example:
local B = LibStub("LibBabble-Module-3.0") -- where Module is what you want.
local BR = B:GetReverseLookupTable()
assert(BR["Some localized word"] == "Some english word")
assert(BR["Some localized word that doesn't exist"] == nil)
-----------------------------------------------------------------------------]]
function prototype:GetReverseLookupTable()
local db = tablesToDB[self]
local reverse = db.reverse
if reverse then
return reverse
end
return initReverse(self, {})
end
local blank = {}
local weakVal = {__mode="v"}
--[[---------------------------------------------------------------------------
Arguments:
string - the localized word to chek for.
Returns:
An iterator to traverse all English words that map to the given key
Example:
local B = LibStub("LibBabble-Module-3.0") -- where Module is what you want.
for word in B:GetReverseIterator("Some localized word") do
DoSomething(word)
end
-----------------------------------------------------------------------------]]
function prototype:GetReverseIterator(key)
local db = tablesToDB[self]
local reverseIterators = db.reverseIterators
if not reverseIterators then
reverseIterators = setmetatable({}, weakVal)
db.reverseIterators = reverseIterators
elseif reverseIterators[key] then
return pairs(reverseIterators[key])
end
local t
for k,v in pairs(db.current) do
if v == key then
if not t then
t = {}
end
t[k] = true
end
end
reverseIterators[key] = t or blank
return pairs(reverseIterators[key])
end
--[[---------------------------------------------------------------------------
Returns:
An iterator to traverse all translations English to localized.
Example:
local B = LibStub("LibBabble-Module-3.0") -- where Module is what you want.
for english, localized in B:Iterate() do
DoSomething(english, localized)
end
-----------------------------------------------------------------------------]]
function prototype:Iterate()
local db = tablesToDB[self]
return pairs(db.current)
end
-- #NODOC
-- modules need to call this to set the base table
function prototype:SetBaseTranslations(base)
local db = tablesToDB[self]
local oldBase = db.base
if oldBase then
for k in pairs(oldBase) do
oldBase[k] = nil
end
for k, v in pairs(base) do
oldBase[k] = v
end
base = oldBase
else
db.base = base
end
for k,v in pairs(base) do
if v == true then
base[k] = k
end
end
end
local function init(module)
local db = tablesToDB[module]
if db.lookup then
initLookup(module, db.lookup)
end
if db.reverse then
initReverse(module, db.reverse)
end
db.reverseIterators = nil
end
-- #NODOC
-- modules need to call this to set the current table. if current is true, use the base table.
function prototype:SetCurrentTranslations(current)
local db = tablesToDB[self]
if current == true then
db.current = db.base
else
local oldCurrent = db.current
if oldCurrent then
for k in pairs(oldCurrent) do
oldCurrent[k] = nil
end
for k, v in pairs(current) do
oldCurrent[k] = v
end
current = oldCurrent
else
db.current = current
end
end
init(self)
end
for namespace, db in pairs(data) do
setmetatable(db.module, prototype_mt)
init(db.module)
end
-- #NODOC
-- modules need to call this to create a new namespace.
function LibBabble:New(namespace, minor)
local module, oldminor = LibStub:NewLibrary(namespace, minor)
if not module then
return
end
if not oldminor then
local db = {
module = module,
}
data[namespace] = db
tablesToDB[module] = db
else
for k,v in pairs(module) do
module[k] = nil
end
end
setmetatable(module, prototype_mt)
return module
end
+239
View File
@@ -0,0 +1,239 @@
--[[
Name: LibBabble-Class-3.0
Revision: $Rev: 50 $
Author(s): ckknight (ckknight@gmail.com)
Website: http://ckknight.wowinterface.com/
Dependencies: None
License: MIT
]]
local MAJOR_VERSION = "LibBabble-Class-3.0"
local MINOR_VERSION = 90000 + tonumber(("$Revision: 50 $"):match("%d+"))
if not LibStub then error(MAJOR_VERSION .. " requires LibStub.") end
local lib = LibStub("LibBabble-3.0"):New(MAJOR_VERSION, MINOR_VERSION)
if not lib then return end
local GAME_LOCALE = GetLocale()
lib:SetBaseTranslations {
Warlock = true,
Warrior = true,
Hunter = true,
Mage = true,
Priest = true,
Druid = true,
Paladin = true,
Shaman = true,
Rogue = true,
Deathknight = "Death Knight",
WARLOCK = true,
WARRIOR = true,
HUNTER = true,
MAGE = true,
PRIEST = true,
DRUID = true,
PALADIN = true,
SHAMAN = true,
ROGUE = true,
DEATHKNIGHT = "Death Knight",
}
if GAME_LOCALE == "enUS" then
lib:SetCurrentTranslations(true)
elseif GAME_LOCALE == "deDE" then
lib:SetCurrentTranslations {
["Warlock"] = "Hexenmeister",
["Warrior"] = "Krieger",
["Hunter"] = "Jäger",
["Mage"] = "Magier",
["Priest"] = "Priester",
["Druid"] = "Druide",
["Paladin"] = "Paladin",
["Shaman"] = "Schamane",
["Rogue"] = "Schurke",
["Deathknight"] = "Todesritter",
["WARLOCK"] = "Hexenmeisterin",
["WARRIOR"] = "Kriegerin",
["HUNTER"] = "Jägerin",
["MAGE"] = "Magierin",
["PRIEST"] = "Priesterin",
["DRUID"] = "Druidin",
["PALADIN"] = "Paladin",
["SHAMAN"] = "Schamanin",
["ROGUE"] = "Schurkin",
["DEATHKNIGHT"] = "Todesritter",
}
elseif GAME_LOCALE == "frFR" then
lib:SetCurrentTranslations {
["Warlock"] = "Démoniste",
["Warrior"] = "Guerrier",
["Hunter"] = "Chasseur",
["Mage"] = "Mage",
["Priest"] = "Prêtre",
["Druid"] = "Druide",
["Paladin"] = "Paladin",
["Shaman"] = "Chaman",
["Rogue"] = "Voleur",
["Deathknight"] = "Chevalier de la mort",
["WARLOCK"] = "Démoniste",
["WARRIOR"] = "Guerrière",
["HUNTER"] = "Chasseresse",
["MAGE"] = "Mage",
["PRIEST"] = "Prêtresse",
["DRUID"] = "Druidesse",
["PALADIN"] = "Paladin",
["SHAMAN"] = "Chamane",
["ROGUE"] = "Voleuse",
["DEATHKNIGHT"] = "Chevalier de la mort",
}
elseif GAME_LOCALE == "zhCN" then
lib:SetCurrentTranslations {
["Warlock"] = "术士",
["Warrior"] = "战士",
["Hunter"] = "猎人",
["Mage"] = "法师",
["Priest"] = "牧师",
["Druid"] = "德鲁伊",
["Paladin"] = "圣骑士",
["Shaman"] = "萨满祭司",
["Rogue"] = "潜行者",
["Deathknight"] = "死亡骑士",
["WARLOCK"] = "术士",
["WARRIOR"] = "战士",
["HUNTER"] = "猎人",
["MAGE"] = "法师",
["PRIEST"] = "牧师",
["DRUID"] = "德鲁伊",
["PALADIN"] = "圣骑士",
["SHAMAN"] = "萨满祭司",
["ROGUE"] = "潜行者",
["DEATHKNIGHT"] = "死亡骑士",
}
elseif GAME_LOCALE == "zhTW" then
lib:SetCurrentTranslations {
["Warlock"] = "術士",
["Warrior"] = "戰士",
["Hunter"] = "獵人",
["Mage"] = "法師",
["Priest"] = "牧師",
["Druid"] = "德魯伊",
["Paladin"] = "聖騎士",
["Shaman"] = "薩滿",
["Rogue"] = "盜賊",
["Deathknight"] = "死亡騎士",
["WARLOCK"] = "術士",
["WARRIOR"] = "戰士",
["HUNTER"] = "獵人",
["MAGE"] = "法師",
["PRIEST"] = "牧師",
["DRUID"] = "德魯伊",
["PALADIN"] = "聖騎士",
["SHAMAN"] = "薩滿",
["ROGUE"] = "盜賊",
["DEATHKNIGHT"] = "死亡騎士",
}
elseif GAME_LOCALE == "koKR" then
lib:SetCurrentTranslations {
["Warlock"] = "흑마법사",
["Warrior"] = "전사",
["Hunter"] = "사냥꾼",
["Mage"] = "마법사",
["Priest"] = "사제",
["Druid"] = "드루이드",
["Paladin"] = "성기사",
["Shaman"] = "주술사",
["Rogue"] = "도적",
["Deathknight"] = "죽음의 기사",
["WARLOCK"] = "흑마법사",
["WARRIOR"] = "전사",
["HUNTER"] = "사냥꾼",
["MAGE"] = "마법사",
["PRIEST"] = "사제",
["DRUID"] = "드루이드",
["PALADIN"] = "성기사",
["SHAMAN"] = "주술사",
["ROGUE"] = "도적",
["DEATHKNIGHT"] = "죽음의 기사",
}
elseif GAME_LOCALE == "esES" then
lib:SetCurrentTranslations {
["Warlock"] = "Brujo",
["Warrior"] = "Guerrero",
["Hunter"] = "Cazador",
["Mage"] = "Mago",
["Priest"] = "Sacerdote",
["Druid"] = "Druida",
["Paladin"] = "Paladín",
["Shaman"] = "Chamán",
["Rogue"] = "Pícaro",
["Deathknight"] = "Caballero de la muerte",
["WARLOCK"] = "Bruja",
["WARRIOR"] = "Guerrera",
["HUNTER"] = "Cazadora",
["MAGE"] = "Maga",
["PRIEST"] = "Sacerdotisa",
["DRUID"] = "Druida",
["PALADIN"] = "Paladín",
["SHAMAN"] = "Chamán",
["ROGUE"] = "Pícara",
["Deathknight"] = "Caballero de la muerte",
}
elseif GAME_LOCALE == "esMX" then
lib:SetCurrentTranslations {
["Warlock"] = "Brujo",
["Warrior"] = "Guerrero",
["Hunter"] = "Cazador",
["Mage"] = "Mago",
["Priest"] = "Sacerdote",
["Druid"] = "Druida",
["Paladin"] = "Paladín",
["Shaman"] = "Chamán",
["Rogue"] = "Pícaro",
["Deathknight"] = "Caballero de la muerte",
["WARLOCK"] = "Bruja",
["WARRIOR"] = "Guerrera",
["HUNTER"] = "Cazadora",
["MAGE"] = "Maga",
["PRIEST"] = "Sacerdotisa",
["DRUID"] = "Druida",
["PALADIN"] = "Paladín",
["SHAMAN"] = "Chamán",
["ROGUE"] = "Pícara",
["Deathknight"] = "Caballero de la muerte",
}
elseif GAME_LOCALE == "ruRU" then
lib:SetCurrentTranslations {
["Warlock"] = "Чернокнижник",
["Warrior"] = "Воин",
["Hunter"] = "Охотник",
["Mage"] = "Маг",
["Priest"] = "Жрец",
["Druid"] = "Друид",
["Paladin"] = "Паладин",
["Shaman"] = "Шаман",
["Rogue"] = "Разбойник",
["Deathknight"] = "Рыцарь смерти",
["WARLOCK"] = "Чернокнижница",
["WARRIOR"] = "Воин",
["HUNTER"] = "Охотница",
["MAGE"] = "Маг",
["PRIEST"] = "Жрица",
["DRUID"] = "Друид",
["PALADIN"] = "Паладин",
["SHAMAN"] = "Шаманка",
["ROGUE"] = "Разбойница",
["DEATHKNIGHT"] = "Рыцарь смерти",
}
else
error(("%s: Locale %q not supported"):format(MAJOR_VERSION, GAME_LOCALE))
end
File diff suppressed because it is too large Load Diff
+51
View File
@@ -0,0 +1,51 @@
-- $Id: LibStub.lua 103 2014-10-16 03:02:50Z mikk $
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/addons/libstub/ for more info
-- LibStub is hereby placed in the Public Domain
-- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
local LibStub = _G[LIBSTUB_MAJOR]
-- Check to see is this version of the stub is obsolete
if not LibStub or LibStub.minor < LIBSTUB_MINOR then
LibStub = LibStub or {libs = {}, minors = {} }
_G[LIBSTUB_MAJOR] = LibStub
LibStub.minor = LIBSTUB_MINOR
-- LibStub:NewLibrary(major, minor)
-- major (string) - the major version of the library
-- minor (string or number ) - the minor version of the library
--
-- returns nil if a newer or same version of the lib is already present
-- returns empty library object or old library object if upgrade is needed
function LibStub:NewLibrary(major, minor)
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
local oldminor = self.minors[major]
if oldminor and oldminor >= minor then return nil end
self.minors[major], self.libs[major] = minor, self.libs[major] or {}
return self.libs[major], oldminor
end
-- LibStub:GetLibrary(major, [silent])
-- major (string) - the major version of the library
-- silent (boolean) - if true, library is optional, silently return nil if its not found
--
-- throws an error if the library can not be found (except silent is set)
-- returns the library object if found
function LibStub:GetLibrary(major, silent)
if not self.libs[major] and not silent then
error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
end
return self.libs[major], self.minors[major]
end
-- LibStub:IterateLibraries()
--
-- Returns an iterator for the currently registered libraries
function LibStub:IterateLibraries()
return pairs(self.libs)
end
setmetatable(LibStub, { __call = LibStub.GetLibrary })
end
+6
View File
@@ -0,0 +1,6 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="LibStub.lua"/>
<Script file="LibBabble-3.0.lua"/>
<Script file="LibBabble-Class-3.0.lua"/>
<Script file="LibBabble-Zone-3.0.lua"/>
</Ui>
+59
View File
@@ -0,0 +1,59 @@
--Cache global variables
local strmatch = strmatch
--WoW API
local IsAddOnLoaded = IsAddOnLoaded
local checked
local function LoadDebugTools()
if checked then return end
local _, _, _, loadable, _, reason = GetAddOnInfo("!DebugTools")
checked = true
if reason == "MISSING" then return end
if loadable then
LoadAddOn("!DebugTools")
else
EnableAddOn("!DebugTools")
LoadAddOn("!DebugTools")
DisableAddOn("!DebugTools")
end
end
SLASH_FRAMESTACK1 = "/framestack"
SLASH_FRAMESTACK2 = "/fstack"
SlashCmdList["FRAMESTACK"] = function(msg)
LoadDebugTools()
if IsAddOnLoaded("!DebugTools") then
local showHiddenArg, showRegionsArg = strmatch(msg, "^%s*(%S+)%s+(%S+)%s*$")
if (not showHiddenArg or not showRegionsArg) then
showHiddenArg = strmatch(msg, "^%s*(%S+)%s*$")
showRegionsArg = "1"
end
local showHidden = showHiddenArg == "true" or showHiddenArg == "1"
local showRegions = showRegions == "true" or showRegionsArg == "1"
FrameStackTooltip_Toggle(showHidden, showRegions)
end
end
SLASH_EVENTTRACE1 = "/eventtrace"
SLASH_EVENTTRACE2 = "/etrace"
SlashCmdList["EVENTTRACE"] = function(msg)
LoadDebugTools()
if IsAddOnLoaded("!DebugTools") then
EventTraceFrame_HandleSlashCmd(msg)
end
end
SLASH_DUMP1 = "/dump"
SlashCmdList["DUMP"] = function(msg)
LoadDebugTools()
if IsAddOnLoaded("!DebugTools") then
DevTools_DumpCommand(msg)
end
end
+13
View File
@@ -0,0 +1,13 @@
## Interface: 20400
## Title: !DebugTools
## Notes: Tools for developing addons (Blizzard UI Debug Tools)
## Author: Blizzard Entertainment
## Special Thanks: Iriel, Kirov, Esamynn
## Version: 1.0
## Dependencies: !Compatibility
## LoadOnDemand: 1
Compatibility.lua
Dump.lua
Blizzard_DebugTools.lua
Blizzard_DebugTools.xml
+732
View File
@@ -0,0 +1,732 @@
EVENT_TRACE_EVENT_HEIGHT = 16;
EVENT_TRACE_MAX_ENTRIES = 1000;
DEBUGLOCALS_LEVEL = 4;
local _normalFontColor = {1, .82, 0, 1};
EVENT_TRACE_SYSTEM_TIMES = {};
EVENT_TRACE_SYSTEM_TIMES["System"] = true;
EVENT_TRACE_SYSTEM_TIMES["Elapsed"] = true;
EVENT_TRACE_EVENT_COLORS = {};
EVENT_TRACE_EVENT_COLORS["System"] = _normalFontColor;
EVENT_TRACE_EVENT_COLORS["Elapsed"] = {.6, .6, .6, 1};
local _EventTraceFrame;
local _framesSinceLast = 0;
local _timeSinceLast = 0;
local _timer = CreateFrame("FRAME");
_timer:SetScript("OnUpdate", function (self, elapsed) _framesSinceLast = _framesSinceLast + 1; _timeSinceLast = _timeSinceLast + elapsed; end);
function EventTraceFrame_OnLoad(self)
local frameName = self:GetName()
_G[frameName.."Scroll"].thumb = _G[frameName.."ScrollThumb"]
_G[frameName.."DialogBG"]:SetVertexColor(0, 0, 0)
_G[frameName.."DialogBG"]:SetAlpha(0.75)
self.buttons = {};
self.events = {};
self.times = {};
self.rawtimes = {};
self.eventids = {};
self.eventtimes = {};
self.numhandlers = {};
self.slowesthandlers = {};
self.slowesthandlertimes = {}
self.timeSinceLast = {};
self.framesSinceLast = {};
self.args = {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}};
self.ignoredEvents = {};
self.lastIndex = 0;
self.visibleButtons = 0;
_EventTraceFrame = self;
self:SetScript("OnSizeChanged", EventTraceFrame_OnSizeChanged);
EventTraceFrame_OnSizeChanged(self, self:GetWidth(), self:GetHeight());
self:EnableMouse(true);
self:EnableMouseWheel(true);
self:SetScript("OnMouseWheel", EventTraceFrame_OnMouseWheel);
end
local _workTable = {};
function EventTraceFrame_OnEvent (self, event, ...)
if (not self.ignoredEvents[event]) then
if (_framesSinceLast ~= 0 and event ~= "On Update") then
EventTraceFrame_OnEvent(self, "On Update");
end
local nextIndex = self.lastIndex + 1;
if (nextIndex > EVENT_TRACE_MAX_ENTRIES) then
local staleIndex = nextIndex - EVENT_TRACE_MAX_ENTRIES;
self.events[staleIndex] = nil;
self.times[staleIndex] = nil;
self.rawtimes[staleIndex] = nil;
self.timeSinceLast[staleIndex] = nil;
self.framesSinceLast[staleIndex] = nil;
self.eventids[staleIndex] = nil;
self.eventtimes[staleIndex] = nil;
self.numhandlers[staleIndex] = nil;
self.slowesthandlers[staleIndex] = nil;
self.slowesthandlertimes[staleIndex] = nil;
for k, v in next, self.args do
self.args[k][staleIndex] = nil;
end
end
if (event == "Begin Capture" or event == "End Capture") then
self.times[nextIndex] = "System";
if (self.eventsToCapture) then
self.events[nextIndex] = string.format("%s (%s events)", event, tostring(self.eventsToCapture));
else
self.events[nextIndex] = event;
end
self.timeSinceLast[nextIndex] = 0;
self.framesSinceLast[nextIndex] = 0;
elseif (event == "On Update") then
self.times[nextIndex] = "Elapsed";
self.events[nextIndex] = string.format("%.3f sec - %d frame(s)", _timeSinceLast, _framesSinceLast);
self.timeSinceLast[nextIndex] = _timeSinceLast;
self.framesSinceLast[nextIndex] = _framesSinceLast;
_timeSinceLast = 0;
_framesSinceLast = 0;
else
self.events[nextIndex] = event;
local seconds = GetTime();
local minutes = math.floor(math.floor(seconds) / 60);
local hours = math.floor(minutes / 60);
seconds = seconds - 60 * minutes;
minutes = minutes - 60 * hours;
hours = hours % 1000;
self.times[nextIndex] = string.format("%.2d:%.2d:%06.3f", hours, minutes, seconds);
self.timeSinceLast[nextIndex] = 0;
self.framesSinceLast[nextIndex] = 0;
self.eventids[nextIndex] = GetCurrentEventID();
local numArgs = select("#", ...);
for i=1, numArgs do
if (not self.args[i]) then
self.args[i] = {};
end
self.args[i][nextIndex] = select(i, ...);
end
if (self.eventsToCapture) then
self.eventsToCapture = self.eventsToCapture - 1;
end
end
self.rawtimes[nextIndex] = GetTime();
self.lastIndex = nextIndex;
if (self.eventsToCapture and self.eventsToCapture <= 0) then
self.eventsToCapture = nil;
EventTraceFrame_StopEventCapture();
end
end
end
function EventTraceFrame_OnShow(self)
wipe(self.ignoredEvents);
local scrollBar = _G["EventTraceFrameScroll"];
local minValue, maxValue = scrollBar:GetMinMaxValues();
scrollBar:SetValue(maxValue);
end
function EventTraceFrame_OnUpdate (self, elapsed)
EventTraceFrame_Update();
end
function EventTraceFrame_OnSizeChanged (self, width, height)
local numButtonsToDisplay = math.floor((height - 36)/EVENT_TRACE_EVENT_HEIGHT);
local numButtonsCreated = #self.buttons;
if (numButtonsCreated < numButtonsToDisplay) then
for i = numButtonsCreated + 1, numButtonsToDisplay do
local button = CreateFrame("BUTTON", "EventTraceFrameButton" .. i, self, "EventTraceEventTemplate");
button:SetPoint("BOTTOMLEFT", 12, (16 * (i - 1)) + 12);
button:SetPoint("RIGHT", -28, 0);
tinsert(self.buttons, button);
end
for i = self.visibleButtons + 1, numButtonsToDisplay do
self.buttons[i]:Show();
end
self.visibleButtons = numButtonsToDisplay;
EventTraceFrame_Update();
elseif (self.visibleButtons < numButtonsToDisplay) then
for i = self.visibleButtons + 1, numButtonsToDisplay do
self.buttons[i]:Show();
end
self.visibleButtons = numButtonsToDisplay;
EventTraceFrame_Update();
elseif (numButtonsToDisplay < self.visibleButtons) then
for i = numButtonsToDisplay + 1, self.visibleButtons do
self.buttons[i]:Hide();
end
self.visibleButtons = numButtonsToDisplay;
end
end
function EventTraceFrame_Update ()
local offset = 0;
local scrollBar = _G["EventTraceFrameScroll"];
local scrollBarValue = scrollBar:GetValue();
local minValue, maxValue = scrollBar:GetMinMaxValues();
local firstID = max(1, _EventTraceFrame.lastIndex - EVENT_TRACE_MAX_ENTRIES + 1);
local lastID = _EventTraceFrame.lastIndex or 1;
if (firstID >= lastID) then
scrollBar:SetMinMaxValues(firstID-1, lastID);
else
scrollBar:SetMinMaxValues(firstID, lastID);
end
if (scrollBarValue < firstID) then
scrollBar:SetValue(firstID);
scrollBarValue = firstID;
end
if (scrollBarValue < 1) then
scrollBarValue = 1;
elseif (not _EventTraceFrame.selectedEvent) then
if (scrollBarValue == maxValue) then
scrollBar:SetValue(_EventTraceFrame.lastIndex);
end
end
for i = 1, _EventTraceFrame.visibleButtons do
local button = _EventTraceFrame.buttons[i];
if (button) then
local index = scrollBarValue - (i - 1);
local event = _EventTraceFrame.events[index];
if (event) then
local timeString = _EventTraceFrame.times[index]
button.index = index;
button.time:SetText(timeString);
button.event:SetText(event);
if (_EventTraceFrame.eventids[index] and not _EventTraceFrame.eventtimes[index]) then
local eventTime, numHandlers, slowestHandler, slowestHandlerTime = GetEventTime(_EventTraceFrame.eventids[index]);
_EventTraceFrame.eventtimes[index] = eventTime;
_EventTraceFrame.numhandlers[index] = numHandlers;
_EventTraceFrame.slowesthandlers[index] = slowestHandler;
_EventTraceFrame.slowesthandlertimes[index] = slowestHandlerTime;
end
local color = EVENT_TRACE_EVENT_COLORS[event] or EVENT_TRACE_EVENT_COLORS[timeString];
if (color) then
button.time:SetTextColor(unpack(color));
button.event:SetTextColor(unpack(color));
else
local eventTime = _EventTraceFrame.eventtimes[index];
if (eventTime and eventTime > 50.0) then
button.time:SetTextColor(1, 0, 0, 1);
button.event:SetTextColor(1, 0, 0, 1);
elseif (eventTime and eventTime > 20.0) then
button.time:SetTextColor(1, .5, 0, 1);
button.event:SetTextColor(1, .5, 0, 1);
elseif (eventTime and eventTime > 10.0) then
button.time:SetTextColor(1, .8, 0, 1);
button.event:SetTextColor(1, .8, 0, 1);
elseif (eventTime and eventTime > 5.0) then
button.time:SetTextColor(1, 1, .6, 1);
button.event:SetTextColor(1, 1, .6, 1);
else
button.time:SetTextColor(1, 1, 1, 1);
button.event:SetTextColor(1, 1, 1, 1);
end
end
button:Show();
if (_EventTraceFrame.selectedEvent) then
if (index == _EventTraceFrame.selectedEvent) then
EventTraceFrameEvent_DisplayTooltip(button);
button:GetHighlightTexture():SetVertexColor(.15, .25, 1, .35);
button:LockHighlight(true);
button.wasSelected = true;
elseif (button.wasSelected) then
button.wasSelected = nil;
button:GetHighlightTexture():SetVertexColor(.8, .8, 1, .15);
button:UnlockHighlight();
end
else
if (button.wasSelected) then
button.wasSelected = nil;
button:GetHighlightTexture():SetVertexColor(.8, .8, 1, .15);
button:UnlockHighlight();
end
end
if (button == GetMouseFocus()) then
EventTraceFrameEvent_OnEnter(button);
else
button.HideButton:Hide();
end
else
button.index = index;
button:Hide();
end
end
end
EventTraceFrame_UpdateKeyboardStatus();
end
function EventTraceFrame_StartEventCapture()
if (_EventTraceFrame.started) then
return;
end
EventHandler_Enable()
_EventTraceFrame.started = true;
_framesSinceLast = 0;
_timeSinceLast = 0;
_EventTraceFrame:RegisterAllEvents();
EventTraceFrame_OnEvent(_EventTraceFrame, "Begin Capture");
end
function EventTraceFrame_StopEventCapture()
if (not _EventTraceFrame.started) then
return;
end
EventHandler_Disable()
_EventTraceFrame.started = false;
_framesSinceLast = 0;
_timeSinceLast = 0;
_EventTraceFrame:UnregisterAllEvents();
EventTraceFrame_OnEvent(_EventTraceFrame, "End Capture");
end
function EventTraceFrame_HandleSlashCmd(msg)
msg = strlower(msg);
if (msg == "start") then
EventTraceFrame_StartEventCapture();
elseif (msg == "stop") then
EventTraceFrame_StopEventCapture();
elseif (tonumber(msg) and tonumber(msg) > 0) then
if (not _EventTraceFrame.started) then
_EventTraceFrame.eventsToCapture = tonumber(msg);
EventTraceFrame_StartEventCapture();
end
elseif (msg == "") then
if (not _EventTraceFrame:IsShown()) then
_EventTraceFrame:Show();
if (_EventTraceFrame.started == nil) then
EventTraceFrame_StartEventCapture();
end
else
_EventTraceFrame:Hide();
end
end
end
function EventTraceFrame_OnMouseWheel(self, delta)
local scrollBar = _G["EventTraceFrameScroll"];
local minVal, maxVal = scrollBar:GetMinMaxValues();
local currentValue = scrollBar:GetValue();
local newValue = currentValue - (delta * 3);
newValue = max(newValue, minVal);
newValue = min(newValue, maxVal);
if (newValue ~= currentValue) then
scrollBar:SetValue(newValue);
end
end
function EventTraceFrame_UpdateKeyboardStatus()
if (_EventTraceFrame.selectedEvent) then
local focus = GetMouseFocus();
if (focus == _EventTraceFrame or (focus and focus:GetParent() == _EventTraceFrame)) then
_EventTraceFrame:EnableKeyboard(true);
return;
end
end
_EventTraceFrame:EnableKeyboard(false);
end
function EventTraceFrame_OnKeyUp(self, key)
if (key == "ESCAPE") then
self.selectedEvent = nil;
EventTraceTooltip:Hide();
EventTraceFrame_Update();
end
end
function EventTraceFrame_RemoveEvent(i)
if (i >= 1 and i <= EventTraceFrame.lastIndex) then
tremove(EventTraceFrame.events, i);
tremove(EventTraceFrame.times, i);
tremove(EventTraceFrame.rawtimes, i);
tremove(EventTraceFrame.timeSinceLast, i);
tremove(EventTraceFrame.framesSinceLast, i);
tremove(EventTraceFrame.eventtimes, i);
tremove(EventTraceFrame.eventids, i);
tremove(EventTraceFrame.numhandlers, i);
tremove(EventTraceFrame.slowesthandlers, i);
tremove(EventTraceFrame.slowesthandlertimes, i);
for k, v in next, EventTraceFrame.args do
for j = i, EventTraceFrame.lastIndex do
EventTraceFrame.args[k][j] = EventTraceFrame.args[k][j+1];
end
end
EventTraceFrame.lastIndex = EventTraceFrame.lastIndex-1;
end
end
local TIME_LABEL = "Time:";
local DETAILS_LABEL = "Details:";
local SLOWEST_LABEL = "Slowest:";
local ARGUMENT_LABEL_FORMAT = "arg %d:";
local NUM_HANDLERS_FORMAT = "(%d handlers)";
local EVENT_TIME_FORMAT = "%.2fms";
local function EventTrace_FormatArgValue (val)
if (type(val) == "string") then
return string.format('"%s"', val);
elseif (type(val) == "number") then
return tostring(val);
elseif (type(val) == "boolean") then
return string.format('|cffaaaaff%s|r', tostring(val));
elseif (type(val) == "table" or type(val) == "bool") then
return string.format('|cffffaaaa%s|r', tostring(val));
end
end
function EventTraceFrameEvent_DisplayTooltip (eventButton)
local index = eventButton.index;
if (not index) then
return;
end
local tooltip = _G["EventTraceTooltip"];
tooltip:SetOwner(eventButton, "ANCHOR_NONE");
tooltip:SetPoint("TOPLEFT", eventButton, "TOPRIGHT", 24, 2);
local timeString = _EventTraceFrame.times[index]
if (EVENT_TRACE_SYSTEM_TIMES[timeString]) then
tooltip:AddLine(timeString, 1, 1, 1);
tooltip:AddDoubleLine(TIME_LABEL, _EventTraceFrame.rawtimes[index], 1, .82, 0, 1, 1, 1);
tooltip:AddDoubleLine(DETAILS_LABEL, _EventTraceFrame.events[index], 1, .82, 0, 1, 1, 1);
else
tooltip:AddLine(_EventTraceFrame.events[index], 1, 1, 1);
local eventTime = _EventTraceFrame.eventtimes[index];
if (eventTime) then
if (eventTime < 0) then
eventTime = "?";
else
eventTime = format(EVENT_TIME_FORMAT, eventTime);
end
tooltip:AddDoubleLine(TIME_LABEL, eventTime .. " " .. format(NUM_HANDLERS_FORMAT, _EventTraceFrame.numhandlers[index] or 0), 1, .82, 0, 1, 1, 1);
else
tooltip:AddDoubleLine(TIME_LABEL, _EventTraceFrame.rawtimes[index], 1, .82, 0, 1, 1, 1);
end
if (_EventTraceFrame.slowesthandlers[index]) then
tooltip:AddDoubleLine(SLOWEST_LABEL, format("%s (%.2fms)", _EventTraceFrame.slowesthandlers[index], _EventTraceFrame.slowesthandlertimes[index]), 1, .82, 0, 1, 1, 1);
end
for k, v in ipairs(EventTraceFrame.args) do
if (v[index]) then
tooltip:AddDoubleLine(format(ARGUMENT_LABEL_FORMAT, k), EventTrace_FormatArgValue(v[index]), 1, .82, 0, 1, 1, 1);
end
end
end
tooltip:Show();
end
function EventTraceFrameEvent_OnEnter (self)
if (not EVENT_TRACE_SYSTEM_TIMES[EventTraceFrame.times[self.index]]) then
self.HideButton:Show();
else
self.HideButton:Hide();
end
if (_EventTraceFrame.selectedEvent) then
return;
else
EventTraceFrameEvent_DisplayTooltip(self);
end
end
function EventTraceFrameEvent_OnLeave (self)
if (not self.HideButton == GetMouseFocus()) then
self.HideButton:Hide();
end
if (not _EventTraceFrame.selectedEvent) then
EventTraceTooltip:Hide();
end
end
function EventTraceFrameEvent_OnClick (self)
if (_EventTraceFrame.selectedEvent == self.index) then
_EventTraceFrame.selectedEvent = nil;
else
_EventTraceFrame.selectedEvent = self.index;
end
EventTraceFrame_Update();
end
function EventTraceFrameEventHideButton_OnClick (button)
local eventName = button:GetParent().event:GetText();
EventTraceFrame.ignoredEvents[eventName] = 1;
EventTraceFrame.selectedEvent = nil;
for i = EventTraceFrame.lastIndex, 1, -1 do
if (EventTraceFrame.events[i] == eventName) then
EventTraceFrame_RemoveEvent(i);
end
end
local lastWasElapsed = false;
for i = EventTraceFrame.lastIndex, 1, -1 do
if (EventTraceFrame.times[i] == "Elapsed") then
if (lastWasElapsed) then
EventTraceFrame.timeSinceLast[i] = EventTraceFrame.timeSinceLast[i] + EventTraceFrame.timeSinceLast[i+1];
EventTraceFrame.framesSinceLast[i] = EventTraceFrame.framesSinceLast[i] + EventTraceFrame.framesSinceLast[i+1];
EventTraceFrame.events[i] = string.format(string.format("%.3f sec", EventTraceFrame.timeSinceLast[i]) .. " - %d frame(s)", EventTraceFrame.framesSinceLast[i]);
EventTraceFrame_RemoveEvent(i+1);
end
lastWasElapsed = true;
else
lastWasElapsed = false;
end
end
EventTraceFrame_Update();
end
local ERROR_FORMAT = [[|cffffd200Message:|r|cffffffff %s|r
|cffffd200Time:|r|cffffffff %s|r
|cffffd200Count:|r|cffffffff %s|r
|cffffd200Stack:|r|cffffffff %s|r]];
local WARNING_AS_ERROR_FORMAT = [[|cffffd200Message:|r|cffffffff %s|r
|cffffd200Time:|r|cffffffff %s|r
|cffffd200Count:|r|cffffffff %s|r]];
local WARNING_FORMAT = "Lua Warning:\n"..WARNING_AS_ERROR_FORMAT;
local INDEX_ORDER_FORMAT = "%d / %d"
local _ScriptErrorsFrame;
function ScriptErrorsFrame_OnLoad (self)
local frameName = self:GetName()
self.title = _G[frameName.."Title"]
self.indexLabel = _G[frameName.."IndexLabel"]
self.reload = _G[frameName.."Reload"]
self.previous = _G[frameName.."Previous"]
self.next = _G[frameName.."Next"]
self.close = _G[frameName.."CloseButton"]
self.title:SetText(LUA_ERROR);
self:RegisterForDrag("LeftButton");
self.seen = {};
self.order = {};
self.count = {};
self.messages = {};
self.times = {};
_ScriptErrorsFrame = self;
end
function ScriptErrorsFrame_OnShow (self)
ScriptErrorsFrame_Update();
end
function ScriptErrorsFrame_OnError (message, keepHidden)
local stack = debugstack(DEBUGLOCALS_LEVEL);
local messageStack = message..stack;
if (_ScriptErrorsFrame) then
local index = _ScriptErrorsFrame.seen[messageStack];
if (index) then
_ScriptErrorsFrame.count[index] = _ScriptErrorsFrame.count[index] + 1;
_ScriptErrorsFrame.messages[index] = message;
_ScriptErrorsFrame.times[index] = date();
else
tinsert(_ScriptErrorsFrame.order, stack);
index = #_ScriptErrorsFrame.order;
_ScriptErrorsFrame.count[index] = 1;
_ScriptErrorsFrame.messages[index] = message;
_ScriptErrorsFrame.times[index] = date();
_ScriptErrorsFrame.seen[messageStack] = index;
end
if (not _ScriptErrorsFrame:IsShown() and not keepHidden) then
_ScriptErrorsFrame.index = index;
_ScriptErrorsFrame:Show();
else
ScriptErrorsFrame_Update();
end
end
end
function ScriptErrorsFrame_Update ()
local editBox = ScriptErrorsFrameScrollFrameText;
local index = _ScriptErrorsFrame.index;
if (not index or not _ScriptErrorsFrame.order[index]) then
index = #_ScriptErrorsFrame.order;
_ScriptErrorsFrame.index = index;
end
if (index == 0) then
editBox:SetText("");
ScriptErrorsFrame_UpdateButtons();
return;
end
local text = string.format(
ERROR_FORMAT,
_ScriptErrorsFrame.messages[index],
_ScriptErrorsFrame.times[index],
_ScriptErrorsFrame.count[index],
_ScriptErrorsFrame.order[index]
);
local parent = editBox:GetParent();
local prevText = editBox.text;
editBox.text = text;
if (prevText ~= text) then
editBox:SetText(text);
editBox:HighlightText(0);
editBox:SetCursorPosition(0);
else
ScrollingEdit_OnTextChanged(editBox, parent);
end
parent:SetVerticalScroll(0);
ScriptErrorsFrame_UpdateButtons();
end
function ScriptErrorsFrame_UpdateButtons ()
local index = _ScriptErrorsFrame.index;
local numErrors = #_ScriptErrorsFrame.order;
if (index == 0) then
_ScriptErrorsFrame.next:Disable();
_ScriptErrorsFrame.previous:Disable();
else
if (numErrors == 1) then
_ScriptErrorsFrame.next:Disable();
_ScriptErrorsFrame.previous:Disable();
elseif (index == 1) then
_ScriptErrorsFrame.next:Enable();
_ScriptErrorsFrame.previous:Disable();
elseif (index == numErrors) then
_ScriptErrorsFrame.next:Disable();
_ScriptErrorsFrame.previous:Enable();
else
_ScriptErrorsFrame.next:Enable();
_ScriptErrorsFrame.previous:Enable();
end
end
_ScriptErrorsFrame.indexLabel:SetText(string.format(INDEX_ORDER_FORMAT, index, numErrors));
end
function ScriptErrorsFrame_DeleteError (index)
if (_ScriptErrorsFrame.order[index]) then
_ScriptErrorsFrame.seen[_ScriptErrorsFrame.messages[index] .. _ScriptErrorsFrame.order[index]] = nil;
tremove(_ScriptErrorsFrame.order, index);
tremove(_ScriptErrorsFrame.messages, index);
tremove(_ScriptErrorsFrame.times, index);
tremove(_ScriptErrorsFrame.count, index);
end
end
function ScriptErrorsFrameButton_OnClick (self)
local id = self:GetID();
if (id == 1) then
_ScriptErrorsFrame.index = _ScriptErrorsFrame.index + 1;
else
_ScriptErrorsFrame.index = _ScriptErrorsFrame.index - 1;
end
ScriptErrorsFrame_Update();
end
function DebugTooltip_OnLoad(self)
self:SetFrameLevel(self:GetFrameLevel() + 2)
self:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
self:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
self.statusBar2 = getglobal(self:GetName().."StatusBar2")
self.statusBar2Text = getglobal(self:GetName().."StatusBar2Text")
end
function FrameStackTooltip_OnDisplaySizeChanged(self)
local height = GetScreenHeight()
if (height > 768) then
self:SetScale(768 / height)
else
self:SetScale(1)
end
end
function FrameStackTooltip_OnLoad(self)
DebugTooltip_OnLoad(self)
FrameStackTooltip_OnDisplaySizeChanged(self)
self:RegisterEvent("DISPLAY_SIZE_CHANGED")
end
function FrameStackTooltip_OnEvent(self, event, ...)
if (event == "DISPLAY_SIZE_CHANGED") then
FrameStackTooltip_OnDisplaySizeChanged(self)
end
end
function FrameStackTooltip_Toggle(showHidden)
local tooltip = _G["FrameStackTooltip"]
if (tooltip:IsVisible()) then
tooltip:Hide()
FrameStackHighlight:Hide()
else
tooltip:SetOwner(UIParent, "ANCHOR_NONE")
tooltip:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -CONTAINER_OFFSET_X - 13, CONTAINER_OFFSET_Y)
tooltip.default = 1
tooltip.showHidden = showHidden
UpdateFrameStack(tooltip, showHidden)
end
end
FRAMESTACK_UPDATE_TIME = .1
local _timeSinceLast = 0
function FrameStackTooltip_OnUpdate(self, elapsed)
_timeSinceLast = _timeSinceLast - elapsed
if (_timeSinceLast <= 0) then
_timeSinceLast = FRAMESTACK_UPDATE_TIME
local highlightFrame = UpdateFrameStack(self, self.showHidden)
FrameStackHighlight:ClearAllPoints();
if (highlightFrame) then
FrameStackHighlight:SetPoint("BOTTOMLEFT", highlightFrame);
FrameStackHighlight:SetPoint("TOPRIGHT", highlightFrame);
FrameStackHighlight:Show();
else
FrameStackHighlight:Hide();
end
end
end
function FrameStackTooltip_OnShow(self)
local parent = self:GetParent() or UIParent
local ps = parent:GetEffectiveScale()
local px, py = parent:GetCenter()
px, py = px * ps, py * ps
local x, y = GetCursorPosition()
self:ClearAllPoints()
if (x > px) then
if (y > py) then
self:SetPoint("BOTTOMLEFT", parent, "BOTTOMLEFT", 20, 20)
else
self:SetPoint("TOPLEFT", parent, "TOPLEFT", 20, -20)
end
else
if (y > py) then
self:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", -20, 20)
else
self:SetPoint("TOPRIGHT", parent, "TOPRIGHT", -20, -20)
end
end
end
FrameStackTooltip_OnEnter = FrameStackTooltip_OnShow
+568
View File
@@ -0,0 +1,568 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Font name="GameFontHighlightSmall" inherits="GameFontNormalSmall" virtual="true">
<Color r="1.0" g="1.0" b="1.0"/>
</Font>
<Font name="GameFontHighlightSmallLeft" inherits="GameFontHighlightSmall" justifyH="LEFT" virtual="true"/>
<Font name="GameFontNormalCenter" inherits="GameFontNormal" justifyH="CENTER" virtual="true"/>
<FontString name="EventTraceTimeFont" font="fonts\arialn.ttf" justifyH="RIGHT" virtual="true">
<FontHeight val="10"/>
<Color r="1" g="1" b="1" a="1"/>
</FontString>
<Button name="EventTraceEventTemplate" virtual="true">
<Size x="0" y="16"/>
<Layers>
<Layer level="ARTWORK">
<FontString name="$parentTime" inherits="EventTraceTimeFont">
<Anchors>
<Anchor point="TOPLEFT"/>
<Anchor point="TOPRIGHT" relativePoint="TOPLEFT">
<Offset x="72" y="0"/>
</Anchor>
<Anchor point="BOTTOM"/>
</Anchors>
</FontString>
<FontString name="$parentEvent" inherits="GameFontHighlightSmallLeft">
<Anchors>
<Anchor point="TOPRIGHT"/>
<Anchor point="TOPLEFT">
<Offset x="80" y="0"/>
</Anchor>
<Anchor point="BOTTOM"/>
</Anchors>
</FontString>
</Layer>
</Layers>
<Frames>
<Button name="$parentHideButton" hidden="true">
<Size x="16" y="8"/>
<Anchors>
<Anchor point="LEFT"/>
</Anchors>
<Scripts>
<OnClick>
EventTraceFrameEventHideButton_OnClick(self);
</OnClick>
<OnLeave>
EventTraceFrameEvent_OnLeave(self:GetParent());
</OnLeave>
</Scripts>
<ButtonText text="X" inherits="GameFontRedSmall">
<Anchors>
<Anchor point="LEFT"/>
</Anchors>
</ButtonText>
</Button>
</Frames>
<Scripts>
<OnLoad>
local frameName = self:GetName();
self.time = _G[frameName.."Time"];
self.event = _G[frameName.."Event"];
self.HideButton = _G[frameName.."HideButton"];
self:GetHighlightTexture():SetAlpha(.15);
</OnLoad>
<OnEnter>
EventTraceFrameEvent_OnEnter(self);
</OnEnter>
<OnLeave>
EventTraceFrameEvent_OnLeave(self);
</OnLeave>
<OnClick>
EventTraceFrameEvent_OnClick(self);
</OnClick>
</Scripts>
<HighlightTexture setAllPoints="true" alphaMode="ADD">
<Color r=".8" g=".8" b="1" a="1"/>
</HighlightTexture>
</Button>
<Frame name="UIPanelDialogTemplate" virtual="true">
<Layers>
<Layer level="OVERLAY">
<Texture name="$parentTopLeft" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Border">
<Size x="64" y="64"/>
<Anchors>
<Anchor point="TOPLEFT"/>
</Anchors>
<TexCoords left="0.501953125" right="0.625" top="0" bottom="1"/>
</Texture>
<Texture name="$parentTopRight" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Border">
<Size x="64" y="64"/>
<Anchors>
<Anchor point="TOPRIGHT"/>
</Anchors>
<TexCoords left="0.625" right="0.75" top="0" bottom="1"/>
</Texture>
<Texture name="$parentTop" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Border">
<Size x="0" y="64"/>
<Anchors>
<Anchor point="TOPLEFT" relativeTo="$parentTopLeft" relativePoint="TOPRIGHT"/>
<Anchor point="TOPRIGHT" relativeTo="$parentTopRight" relativePoint="TOPLEFT"/>
</Anchors>
<TexCoords left="0.25" right="0.369140625" top="0" bottom="1"/>
</Texture>
<Texture name="$parentBottomLeft" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Border">
<Size x="64" y="64"/>
<Anchors>
<Anchor point="BOTTOMLEFT"/>
</Anchors>
<TexCoords left="0.751953125" right="0.875" top="0" bottom="1"/>
</Texture>
<Texture name="$parentBottomRight" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Border">
<Size x="64" y="64"/>
<Anchors>
<Anchor point="BOTTOMRIGHT"/>
</Anchors>
<TexCoords left="0.875" right="1" top="0" bottom="1"/>
</Texture>
<Texture name="$parentBottom" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Border">
<Size x="0" y="64"/>
<Anchors>
<Anchor point="BOTTOMLEFT" relativeTo="$parentBottomLeft" relativePoint="BOTTOMRIGHT"/>
<Anchor point="BOTTOMRIGHT" relativeTo="$parentBottomRight" relativePoint="BOTTOMLEFT"/>
</Anchors>
<TexCoords left="0.376953125" right="0.498046875" top="0" bottom="1"/>
</Texture>
<Texture name="$parentLeft" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Border">
<Size x="64" y="0"/>
<Anchors>
<Anchor point="TOPLEFT" relativeTo="$parentTopLeft" relativePoint="BOTTOMLEFT"/>
<Anchor point="BOTTOMLEFT" relativeTo="$parentBottomLeft" relativePoint="TOPLEFT"/>
</Anchors>
<TexCoords left="0.001953125" right="0.125" top="0" bottom="1"/>
</Texture>
<Texture name="$parentRight" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Border">
<Size x="64" y="0"/>
<Anchors>
<Anchor point="TOPRIGHT" relativeTo="$parentTopRight" relativePoint="BOTTOMRIGHT"/>
<Anchor point="BOTTOMRIGHT" relativeTo="$parentBottomRight" relativePoint="TOPRIGHT"/>
</Anchors>
<TexCoords left="0.1171875" right="0.2421875" top="0" bottom="1"/>
</Texture>
</Layer>
<Layer level="BACKGROUND">
<Texture name="$parentTitleBG" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Title-Background">
<Anchors>
<Anchor point="TOPLEFT">
<Offset x="8" y="-7"/>
</Anchor>
<Anchor point="BOTTOMRIGHT" relativePoint="TOPRIGHT">
<Offset x="-8" y="-24"/>
</Anchor>
</Anchors>
</Texture>
<Texture name="$parentDialogBG" file="Interface\PaperDollInfoFrame\UI-Character-CharacterTab-L1">
<Anchors>
<Anchor point="TOPLEFT">
<Offset x="8" y="-24"/>
</Anchor>
<Anchor point="BOTTOMRIGHT">
<Offset x="-6" y="8"/>
</Anchor>
</Anchors>
<TexCoords left="0.255" right="1" top="0.29" bottom="1"/>
</Texture>
</Layer>
<Layer level="OVERLAY">
<FontString name="$parentTitle" inherits="GameFontNormal">
<Anchors>
<Anchor point="TOPLEFT">
<Offset x="12" y="-8"/>
</Anchor>
<Anchor point="TOPRIGHT">
<Offset x="-32" y="-24"/>
</Anchor>
</Anchors>
</FontString>
</Layer>
</Layers>
<Frames>
<Button name="$parentClose" inherits="UIPanelCloseButton">
<Anchors>
<Anchor point="TOPRIGHT">
<Offset x="2" y="1"/>
</Anchor>
</Anchors>
</Button>
</Frames>
</Frame>
<Frame name="EventTraceFrame" parent="UIParent" movable="true" enableMouse="true" clampedToScreen="true" hidden="true" frameStrata="MEDIUM" toplevel="true">
<Size x="326" y="505"/>
<Anchors>
<Anchor point="LEFT">
<Offset x="64" y="0"/>
</Anchor>
</Anchors>
<Layers>
<Layer level="BACKGROUND">
<Texture name="$parentTitleBG" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Title-Background">
<Anchors>
<Anchor point="TOPLEFT">
<Offset x="9" y="-6"/>
</Anchor>
<Anchor point="BOTTOMRIGHT" relativePoint="TOPRIGHT">
<Offset x="-28" y="-24"/>
</Anchor>
</Anchors>
</Texture>
<Texture name="$parentDialogBG" file="Interface\Tooltips\UI-Tooltip-Background">
<Anchors>
<Anchor point="TOPLEFT">
<Offset x="8" y="-24"/>
</Anchor>
<Anchor point="BOTTOMRIGHT">
<Offset x="-6" y="8"/>
</Anchor>
</Anchors>
<Color r="0" g="0" b="0" a=".75"/>
</Texture>
</Layer>
<Layer level="BORDER">
<Texture name="$parentTopLeft" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Border">
<Size x="64" y="64"/>
<Anchors>
<Anchor point="TOPLEFT"/>
</Anchors>
<TexCoords left="0.501953125" right="0.625" top="0" bottom="1"/>
</Texture>
<Texture name="$parentTopRight" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Border">
<Size x="64" y="64"/>
<Anchors>
<Anchor point="TOPRIGHT"/>
</Anchors>
<TexCoords left="0.625" right="0.75" top="0" bottom="1"/>
</Texture>
<Texture name="$parentTop" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Border">
<Size x="0" y="64"/>
<Anchors>
<Anchor point="TOPLEFT" relativeTo="$parentTopLeft" relativePoint="TOPRIGHT"/>
<Anchor point="TOPRIGHT" relativeTo="$parentTopRight" relativePoint="TOPLEFT"/>
</Anchors>
<TexCoords left="0.25" right="0.369140625" top="0" bottom="1"/>
</Texture>
<Texture name="$parentBottomLeft" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Border">
<Size x="64" y="64"/>
<Anchors>
<Anchor point="BOTTOMLEFT"/>
</Anchors>
<TexCoords left="0.751953125" right="0.875" top="0" bottom="1"/>
</Texture>
<Texture name="$parentBottomRight" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Border">
<Size x="64" y="64"/>
<Anchors>
<Anchor point="BOTTOMRIGHT"/>
</Anchors>
<TexCoords left="0.875" right="1" top="0" bottom="1"/>
</Texture>
<Texture name="$parentBottom" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Border">
<Size x="0" y="64"/>
<Anchors>
<Anchor point="BOTTOMLEFT" relativeTo="$parentBottomLeft" relativePoint="BOTTOMRIGHT"/>
<Anchor point="BOTTOMRIGHT" relativeTo="$parentBottomRight" relativePoint="BOTTOMLEFT"/>
</Anchors>
<TexCoords left="0.376953125" right="0.498046875" top="0" bottom="1"/>
</Texture>
<Texture name="$parentLeft" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Border">
<Size x="64" y="0"/>
<Anchors>
<Anchor point="TOPLEFT" relativeTo="$parentTopLeft" relativePoint="BOTTOMLEFT"/>
<Anchor point="BOTTOMLEFT" relativeTo="$parentBottomLeft" relativePoint="TOPLEFT"/>
</Anchors>
<TexCoords left="0.001953125" right="0.125" top="0" bottom="1"/>
</Texture>
<Texture name="$parentRight" file="Interface\AddOns\!DebugTools\media\UI-GearManager-Border">
<Size x="64" y="0"/>
<Anchors>
<Anchor point="TOPRIGHT" relativeTo="$parentTopRight" relativePoint="BOTTOMRIGHT"/>
<Anchor point="BOTTOMRIGHT" relativeTo="$parentBottomRight" relativePoint="TOPRIGHT"/>
</Anchors>
<TexCoords left="0.1171875" right="0.2421875" top="0" bottom="1"/>
</Texture>
</Layer>
<Layer level="OVERLAY">
<FontString name="$parentTitle" inherits="GameFontNormal" text="EVENTS_LABEL">
<Anchors>
<Anchor point="TOPLEFT">
<Offset x="12" y="-8"/>
</Anchor>
<Anchor point="TOPRIGHT">
<Offset x="-32" y="-8"/>
</Anchor>
</Anchors>
</FontString>
</Layer>
</Layers>
<Frames>
<Button name="$parentCloseButton" inherits="UIPanelCloseButton">
<Size>
<AbsDimension x="32" y="32"/>
</Size>
<Anchors>
<Anchor point="TOPRIGHT">
<Offset x="2" y="1"/>
</Anchor>
</Anchors>
</Button>
<Frame name="$parentTitleButton">
<Anchors>
<Anchor point="TOPLEFT" relativeTo="$parentTitleBG"/>
<Anchor point="BOTTOMRIGHT" relativeTo="$parentTitleBG"/>
</Anchors>
<Frames>
<Frame name="$parentHighlight" setAllPoints="true" hidden="true">
<Layers>
<Layer level="OVERLAY">
<Texture file="Interface\Buttons\UI-ListBox-Highlight" setAllPoints="true">
<Color r="1" g="1" b="1" a="0.4"/>
</Texture>
</Layer>
</Layers>
</Frame>
</Frames>
<Scripts>
<OnLoad>
self:RegisterForDrag("LeftButton");
</OnLoad>
<OnDragStart>
local eventTraceFrame = _G["EventTraceFrame"];
eventTraceFrame.moving = true;
eventTraceFrame:StartMoving();
</OnDragStart>
<OnDragStop>
local eventTraceFrame = _G["EventTraceFrame"];
eventTraceFrame.moving = nil;
eventTraceFrame:StopMovingOrSizing();
</OnDragStop>
</Scripts>
</Frame>
<Slider name="$parentScroll">
<Size x="16" y="0"/>
<Anchors>
<Anchor point="TOPRIGHT">
<Offset x="-7" y="-28"/>
</Anchor>
<Anchor point="BOTTOMRIGHT">
<Offset x="-7" y="10"/>
</Anchor>
</Anchors>
<Layers>
<Layer level="BACKGROUND">
<Texture name="$parentBG" setAllPoints="true">
<Color r=".8" g=".8" b="1" a="0.1"/>
</Texture>
</Layer>
</Layers>
<Scripts>
<OnLoad>
self:SetFrameLevel(self:GetFrameLevel() + 1);
self:SetValue(0);
self:SetValueStep(1);
</OnLoad>
</Scripts>
<ThumbTexture name="$parentThumb" file="Interface\Buttons\UI-ScrollBar-Knob">
<Size x="16" y="16"/>
<TexCoords left="0.25" right="0.75" top="0.25" bottom="0.75"/>
</ThumbTexture>
</Slider>
</Frames>
<Scripts>
<OnLoad>
EventTraceFrame_OnLoad(self);
</OnLoad>
<OnShow>
EventTraceFrame_OnShow(self);
</OnShow>
<OnEvent>
EventTraceFrame_OnEvent(self, event, ...);
</OnEvent>
<OnUpdate>
EventTraceFrame_OnUpdate(self, elapsed);
</OnUpdate>
<OnKeyUp>
EventTraceFrame_OnKeyUp(self, key);
</OnKeyUp>
</Scripts>
</Frame>
<Frame name="ScriptErrorsFrame" inherits="UIPanelDialogTemplate" frameStrata="TOOLTIP" movable="true" enableMouse="true" clampedToScreen="true" hidden="true" toplevel="true">
<Size x="384" y="260"/>
<Anchors>
<Anchor point="CENTER"/>
</Anchors>
<Layers>
<Layer level="ARTWORK">
<FontString name="$parentIndexLabel" font="GameFontNormalCenter">
<Size x="70" y="16"/>
<Anchors>
<Anchor point="BOTTOM">
<Offset x="0" y="16"/>
</Anchor>
</Anchors>
</FontString>
</Layer>
</Layers>
<Frames>
<Frame name="$parentTitleButton">
<Anchors>
<Anchor point="TOPLEFT" relativeTo="$parentTitleBG"/>
<Anchor point="BOTTOMRIGHT" relativeTo="$parentTitleBG"/>
</Anchors>
<Scripts>
<OnLoad>
self:RegisterForDrag("LeftButton");
</OnLoad>
<OnDragStart>
local frame = _G["ScriptErrorsFrame"];
frame.moving = true;
frame:StartMoving();
</OnDragStart>
<OnDragStop>
local frame = _G["ScriptErrorsFrame"];
frame.moving = nil;
frame:StopMovingOrSizing();
</OnDragStop>
</Scripts>
</Frame>
<ScrollFrame name="$parentScrollFrame" inherits="UIPanelScrollFrameTemplate">
<Size x="343" y="194"/>
<Anchors>
<Anchor point="TOPLEFT">
<Offset x="12" y="-30"/>
</Anchor>
</Anchors>
<ScrollChild>
<EditBox name="$parentText" multiLine="true" letters="4000" autoFocus="false">
<Size x="343" y="194"/>
<Scripts>
<OnCursorChanged>
ScrollingEdit_OnCursorChanged(self);
</OnCursorChanged>
<OnUpdate>
ScrollingEdit_OnUpdate(self, elapsed, self:GetParent());
</OnUpdate>
<OnEditFocusGained>
self:HighlightText(0);
</OnEditFocusGained>
<OnEscapePressed>
self:ClearFocus();
</OnEscapePressed>
</Scripts>
<FontString inherits="GameFontHighlightSmall"/>
</EditBox>
</ScrollChild>
</ScrollFrame>
<Button name="$parentReload" inherits="UIPanelButtonTemplate" text="RELOADUI">
<Size x="96" y="24"/>
<Anchors>
<Anchor point="BOTTOMLEFT" relativeTo="$parent">
<Offset x="10" y="12" />
</Anchor>
</Anchors>
<Scripts>
<OnClick>
ReloadUI();
</OnClick>
</Scripts>
</Button>
<Button name="$parentPrevious" id="2">
<Size x="32" y="32"/>
<Anchors>
<Anchor point="BOTTOM">
<Offset x="-50" y="8"/>
</Anchor>
</Anchors>
<NormalTexture file="Interface\Buttons\UI-SpellbookIcon-PrevPage-Up"/>
<PushedTexture file="Interface\Buttons\UI-SpellbookIcon-PrevPage-Down"/>
<DisabledTexture file="Interface\Buttons\UI-SpellbookIcon-PrevPage-Disabled"/>
<HighlightTexture file="Interface\Buttons\UI-Common-MouseHilight" alphaMode="ADD"/>
<Scripts>
<OnClick>
ScriptErrorsFrameButton_OnClick(self);
</OnClick>
</Scripts>
</Button>
<Button name="$parentNext" id="1">
<Size x="32" y="32" />
<Anchors>
<Anchor point="BOTTOM">
<Offset x="50" y="8"/>
</Anchor>
</Anchors>
<NormalTexture file="Interface\Buttons\UI-SpellbookIcon-NextPage-Up"/>
<PushedTexture file="Interface\Buttons\UI-SpellbookIcon-NextPage-Down"/>
<DisabledTexture file="Interface\Buttons\UI-SpellbookIcon-NextPage-Disabled"/>
<HighlightTexture file="Interface\Buttons\UI-Common-MouseHilight" alphaMode="ADD"/>
<Scripts>
<OnClick>
ScriptErrorsFrameButton_OnClick(self);
</OnClick>
</Scripts>
</Button>
<Button name="$parentCloseButton" inherits="UIPanelButtonTemplate" text="CLOSE">
<Size x="96" y="24"/>
<Anchors>
<Anchor point="BOTTOMRIGHT">
<Offset x="-8" y="12"/>
</Anchor>
</Anchors>
<Scripts>
<OnClick>
HideUIPanel(self:GetParent());
</OnClick>
</Scripts>
</Button>
</Frames>
<Scripts>
<OnLoad>
ScriptErrorsFrame_OnLoad(self);
</OnLoad>
<OnShow>
ScriptErrorsFrame_OnShow(self);
</OnShow>
</Scripts>
</Frame>
<GameTooltip name="FrameStackTooltip" frameStrata="TOOLTIP" hidden="true" inherits="GameTooltipTemplate">
<Scripts>
<OnLoad>
FrameStackTooltip_OnLoad(self);
</OnLoad>
<OnShow>
FrameStackTooltip_OnShow(self);
</OnShow>
<OnEnter>
FrameStackTooltip_OnEnter(self);
</OnEnter>
<OnUpdate>
FrameStackTooltip_OnUpdate(self, elapsed);
</OnUpdate>
<OnEvent>
FrameStackTooltip_OnEvent(self, event, ...);
</OnEvent>
</Scripts>
</GameTooltip>
<GameTooltip name="EventTraceTooltip" frameStrata="TOOLTIP" hidden="true" parent="EventTraceFrame" inherits="GameTooltipTemplate">
<Scripts>
<OnLoad>
DebugTooltip_OnLoad(self)
</OnLoad>
</Scripts>
</GameTooltip>
<Frame name="FrameStackHighlight" frameStrata="TOOLTIP">
<Layers>
<Layer level="ARTWORK">
<Texture name="$parentTexture">
<Color r="0.0" g="0.8" b="0.0" a=".4"/>
</Texture>
</Layer>
</Layers>
</Frame>
</Ui>
+196
View File
@@ -0,0 +1,196 @@
--Cache global variables
local format, match = string.format, string.match
local tinsert, tsort, twipe = table.insert, table.sort, table.wipe
local fmod = math.fmod
local pairs = pairs
local tostring = tostring
--WoW API
local GetTime = GetTime
DEBUG_FRAMESTACK = "Frame Stack"
EVENTS_LABEL = "Events"
RELOADUI = "Reload UI"
local eventList = {}
local function EventHandler_OnEvent()
tinsert(eventList, GetTime())
end
local eventHandler = CreateFrame("Frame", "EventHandler", UIParent)
eventHandler:SetScript("OnEvent", EventHandler_OnEvent)
function GetCurrentEventID()
return #eventList
end
function GetEventTime(eventID)
return eventList[eventID]
end
function EventHandler_Enable()
eventHandler:RegisterAllEvents()
end
function EventHandler_Disable()
eventHandler:UnregisterAllEvents()
twipe(eventList)
end
local strataLevels = {
["UNKNOWN"] = 1,
["BACKGROUND"] = 2,
["LOW"] = 3,
["MEDIUM"] = 4,
["HIGH"] = 5,
["DIALOG"] = 6,
["FULLSCREEN"] = 7,
["FULLSCREEN_DIALOG"] = 8,
["TOOLTIP"] = 9,
}
local colorSpecs = {
"|cff6699ff",
"|cff88dddd"
}
local activeColorSpecs = {
"|cffff9966",
"|cffdddd88"
}
local hiddenColorSpecs = {
"|cff666666",
"|cff888888"
}
local frameStackStrata = {}
local frameStackLevels = {}
local frameStackActive = {}
local frameStackList = {}
local function FrameStackSort(b, a)
local sa = strataLevels[frameStackStrata[a]] or -1
local sb = strataLevels[frameStackStrata[b]] or -1
if sa < sb then
return true
elseif sa > sb then
return
end
local sa = frameStackLevels[a] or -1
local sb = frameStackLevels[b] or -1
if sa < sb then
return true
elseif sa > sb then
return
end
return a < b
end
function UpdateFrameStack(tooltip, showHidden)
local x, y = GetCursorPosition()
for i = 1, #frameStackList do
frameStackList[i] = nil
end
for k in pairs(frameStackLevels) do
frameStackLevels[k] = nil
frameStackStrata[k] = nil
frameStackActive[k] = nil
end
local f
local nf = EnumerateFrames()
while nf do
f, nf = nf, EnumerateFrames(nf)
local es = f:GetEffectiveScale() or 1
local Fl, Fb, Fr, Ft = f:GetRect()
Fl = Fl or -1
Fb = Fb or -1
Fr = Fl + (Fr or -1)
Ft = Fb + (Ft or -1)
if (x >= Fl * es) and (x <= Fr * es) and (y >= Fb * es) and (y <= Ft * es) then
local n = f:GetName()
if n and _G[n] == f then
-- Name is ok
elseif n then
n = tostring(f) .. " (" .. n .. ")"
else
n = tostring(f)
end
local s = f:GetFrameStrata() or "nil"
local l = f:GetFrameLevel() or -1
local a
if f:IsVisible() then
if f:IsMouseEnabled() then
a = activeColorSpecs
else
a = colorSpecs
end
elseif showHidden then
a = hiddenColorSpecs
else
a = nil
end
if a then
frameStackLevels[n] = l
frameStackStrata[n] = s
frameStackActive[n] = a
tinsert(frameStackList, n)
end
end
end
frameStackList[#frameStackList + 1] = nil
tsort(frameStackList, FrameStackSort)
tooltip:ClearLines()
tooltip:AddDoubleLine(DEBUG_FRAMESTACK, format("(%.2f,%.2f)", x, y), 1, 1, 1, 1, .82, 0)
local cs, os, ol = 1, nil, nil
local cn = #colorSpecs
local highlighted
local highlightFrame = GetMouseFocus()
for _, n in ipairs(frameStackList) do
local s, l, a = frameStackStrata[n], frameStackLevels[n], frameStackActive[n]
if os ~= s then
tooltip:AddLine(s, 1, 1, 1)
os = s
ol = nil
cs = 1
end
if l ~= ol then
cs = fmod(cs, cn) + 1
ol = l
end
if not highlighted then
local frameName = _G[n] or match(n, "%((.+)%)$") or n
if frameName and frameName == highlightFrame then
tooltip:AddLine("-->" .. (a[cs] or "|cff444444") .. "<" .. l .. "> " .. n .. "|r")
highlighted = true
else
tooltip:AddLine(" " .. (a[cs] or "|cff444444") .. "<" .. l .. "> " .. n .. "|r")
end
else
tooltip:AddLine(" " .. (a[cs] or "|cff444444") .. "<" .. l .. "> " .. n .. "|r")
end
end
tooltip:Show()
return highlightFrame
end
+387
View File
@@ -0,0 +1,387 @@
------------------------------------------------------------------------------
-- Dump.lua
--
-- Contributed by Iriel, Esamynn and Kirov from DevTools v1.11
-- /dump Implementation
--
-- Globals: DevTools, SLASH_DEVTOOLSDUMP1, DevTools_Dump, DevTools_RunDump
-- Globals: DEVTOOLS_MAX_ENTRY_CUTOFF, DEVTOOLS_LONG_STRING_CUTOFF
-- Globals: DEVTOOLS_DEPTH_CUTOFF, DEVTOOLS_INDENT
-- Globals: DEVTOOLS_USE_TABLE_CACHE, DEVTOOLS_USE_FUNCTION_CACHE
-- Globals: DEVTOOLS_USE_USERDATA_CACHE
---------------------------------------------------------------------------
local DT = {};
DEVTOOLS_MAX_ENTRY_CUTOFF = 30; -- Maximum table entries shown
DEVTOOLS_LONG_STRING_CUTOFF = 200; -- Maximum string size shown
DEVTOOLS_DEPTH_CUTOFF = 10; -- Maximum table depth
DEVTOOLS_USE_TABLE_CACHE = true; -- Look up table names
DEVTOOLS_USE_FUNCTION_CACHE = true; -- Look up function names
DEVTOOLS_USE_USERDATA_CACHE = true; -- Look up userdata names
DEVTOOLS_INDENT=' '; -- Indentation string
local DEVTOOLS_TYPE_COLOR="|cff88ff88";
local DEVTOOLS_TABLEREF_COLOR="|cffffcc00";
local DEVTOOLS_CUTOFF_COLOR="|cffff0000";
local DEVTOOLS_TABLEKEY_COLOR="|cff88ccff";
local FORMATS = {};
-- prefix type suffix
FORMATS["opaqueTypeVal"] = "%s" .. DEVTOOLS_TYPE_COLOR .. "<%s>|r%s";
-- prefix type name suffix
FORMATS["opaqueTypeValName"] = "%s" .. DEVTOOLS_TYPE_COLOR .. "<%s %s>|r%s";
-- type
FORMATS["opaqueTypeKey"] = "<%s>";
-- type name
FORMATS["opaqueTypeKeyName"] = "<%s %s>";
-- value
FORMATS["bracketTableKey"] = "[%s]";
-- prefix value
FORMATS["tableKeyAssignPrefix"] = DEVTOOLS_TABLEKEY_COLOR .. "%s%s|r=";
-- prefix cutoff
FORMATS["tableEntriesSkipped"] = "%s" .. DEVTOOLS_CUTOFF_COLOR .. "<skipped %s>|r";
-- prefix suffix
FORMATS["tableTooDeep"] = "%s" .. DEVTOOLS_CUTOFF_COLOR .. "<table (too deep)>|r%s";
-- prefix value suffix
FORMATS["simpleValue"] = "%s%s%s";
-- prefix tablename suffix
FORMATS["tableReference"] = "%s" .. DEVTOOLS_TABLEREF_COLOR .. "%s|r%s";
-- Grab a copy various oft-used functions
local rawget = rawget;
local type = type;
local string_len = string.len;
local string_sub = string.sub;
local string_gsub = string.gsub;
local string_format = string.format;
local string_match = string.match;
local function WriteMessage(msg)
DEFAULT_CHAT_FRAME:AddMessage(msg);
end
local function prepSimple(val, context)
local valType = type(val);
if (valType == "nil") then
return "nil";
elseif (valType == "number") then
return val;
elseif (valType == "boolean") then
if (val) then
return "true";
else
return "false";
end
elseif (valType == "string") then
local l = string_len(val);
if ((l > DEVTOOLS_LONG_STRING_CUTOFF) and
(DEVTOOLS_LONG_STRING_CUTOFF > 0)) then
local more = l - DEVTOOLS_LONG_STRING_CUTOFF;
val = string_sub(val, 1, DEVTOOLS_LONG_STRING_CUTOFF);
return string_gsub(string_format("%q...+%s",val,more),"[|]", "||");
else
return string_gsub(string_format("%q",val),"[|]", "||");
end
elseif (valType == "function") then
local fName = context:GetFunctionName(val);
if (fName) then
return string_format(FORMATS.opaqueTypeKeyName, valType, fName);
else
return string_format(FORMATS.opaqueTypeKey, valType);
end
return string_format(FORMATS.opaqueTypeKey, valType);
elseif (valType == "userdata") then
local uName = context:GetUserdataName(val);
if (uName) then
return string_format(FORMATS.opaqueTypeKeyName, valType, uName);
else
return string_format(FORMATS.opaqueTypeKey, valType);
end
elseif (valType == 'table') then
local tName = context:GetTableName(val);
if (tName) then
return string_format(FORMATS.opaqueTypeKeyName, valType, tName);
else
return string_format(FORMATS.opaqueTypeKey, valType);
end
end
error("Bad type '" .. valType .. "' to prepSimple");
end
local function prepSimpleKey(val, context)
local valType = type(val);
if (valType == "string") then
local l = string_len(val);
if ((l <= DEVTOOLS_LONG_STRING_CUTOFF) or
(DEVTOOLS_LONG_STRING_CUTOFF <= 0)) then
if (string_match(val, "^[a-zA-Z_][a-zA-Z0-9_]*$")) then
return val;
end
end
end
return string_format(FORMATS.bracketTableKey, prepSimple(val, context));
end
local function DevTools_InitFunctionCache(context)
local ret = {};
for _,k in ipairs(DT.functionSymbols) do
local v = getglobal(k);
if (type(v) == 'function') then
ret[v] = '[' .. k .. ']';
end
end
for k,v in pairs(getfenv(0)) do
if (type(v) == 'function') then
if (not ret[v]) then
ret[v] = '[' .. k .. ']';
end
end
end
return ret;
end
local function DevTools_InitUserdataCache(context)
local ret = {};
for _,k in ipairs(DT.userdataSymbols) do
local v = getglobal(k);
if (type(v) == 'table') then
local u = rawget(v,0);
if (type(u) == 'userdata') then
ret[u] = k .. '[0]';
end
end
end
for k,v in pairs(getfenv(0)) do
if (type(v) == 'table') then
local u = rawget(v, 0);
if (type(u) == 'userdata') then
if (not ret[u]) then
ret[u] = k .. '[0]';
end
end
end
end
return ret;
end
local function DevTools_Cache_Nil(self, value, newName)
return nil;
end
local function DevTools_Cache_Function(self, value, newName)
if (not self.fCache) then
self.fCache = DevTools_InitFunctionCache(self);
end
local name = self.fCache[value];
if ((not name) and newName) then
self.fCache[value] = newName;
end
return name;
end
local function DevTools_Cache_Userdata(self, value, newName)
if (not self.uCache) then
self.uCache = DevTools_InitUserdataCache(self);
end
local name = self.uCache[value];
if ((not name) and newName) then
self.uCache[value] = newName;
end
return name;
end
local function DevTools_Cache_Table(self, value, newName)
if (not self.tCache) then
self.tCache = {};
end
local name = self.tCache[value];
if ((not name) and newName) then
self.tCache[value] = newName;
end
return name;
end
local function DevTools_Write(self, msg)
DEFAULT_CHAT_FRAME:AddMessage(msg);
end
local DevTools_DumpValue;
local function DevTools_DumpTableContents(val, prefix, firstPrefix, context)
local showCount = 0;
local oldDepth = context.depth;
local oldKey = context.key;
-- Use this to set the cache name
context:GetTableName(val, oldKey or 'value');
local iter = pairs(val);
local nextK, nextV = iter(val, nil);
while (nextK) do
local k,v = nextK, nextV;
nextK, nextV = iter(val, k);
showCount = showCount + 1;
if ((showCount <= DEVTOOLS_MAX_ENTRY_CUTOFF) or (DEVTOOLS_MAX_ENTRY_CUTOFF <= 0)) then
local prepKey = prepSimpleKey(k, context);
if (oldKey == nil) then
context.key = prepKey;
elseif (string_sub(prepKey, 1, 1) == "[") then
context.key = oldKey .. prepKey
else
context.key = oldKey .. "." .. prepKey
end
context.depth = oldDepth + 1;
local rp = string_format(FORMATS.tableKeyAssignPrefix, firstPrefix, prepKey);
firstPrefix = prefix;
DevTools_DumpValue(v, prefix, rp, (nextK and ",") or '', context);
end
end
local cutoff = showCount - DEVTOOLS_MAX_ENTRY_CUTOFF;
if ((cutoff > 0) and (DEVTOOLS_MAX_ENTRY_CUTOFF > 0)) then
context:Write(string_format(FORMATS.tableEntriesSkipped,firstPrefix, cutoff));
end
context.key = oldKey;
context.depth = oldDepth;
return (showCount > 0)
end
-- Return the specified value
function DevTools_DumpValue(val, prefix, firstPrefix, suffix, context)
local valType = type(val);
if (valType == "userdata") then
local uName = context:GetUserdataName(val, 'value');
if (uName) then
context:Write(string_format(FORMATS.opaqueTypeValName, firstPrefix, valType, uName, suffix));
else
context:Write(string_format(FORMATS.opaqueTypeVal, firstPrefix, valType, suffix));
end
return;
elseif (valType == "function") then
local fName = context:GetFunctionName(val, 'value');
if (fName) then
context:Write(string_format(FORMATS.opaqueTypeValName, firstPrefix, valType, fName, suffix));
else
context:Write(string_format(FORMATS.opaqueTypeVal, firstPrefix, valType, suffix));
end
return;
elseif (valType ~= "table") then
context:Write(string_format(FORMATS.simpleValue, firstPrefix,prepSimple(val, context), suffix));
return;
end
local cacheName = context:GetTableName(val);
if (cacheName) then
context:Write(string_format(FORMATS.tableReference, firstPrefix, cacheName, suffix));
return;
end
if ((context.depth >= DEVTOOLS_DEPTH_CUTOFF) and (DEVTOOLS_DEPTH_CUTOFF > 0)) then
context:Write(string_format(FORMATS.tableTooDeep, firstPrefix, suffix));
return;
end
firstPrefix = firstPrefix .. "{";
local oldPrefix = prefix;
prefix = prefix .. DEVTOOLS_INDENT;
context:Write(firstPrefix);
firstPrefix = prefix;
local anyContents = DevTools_DumpTableContents(val, prefix, firstPrefix, context);
context:Write(oldPrefix .. "}" .. suffix);
end
local function Pick_Cache_Function(func, setting)
if (setting) then
return func;
else
return DevTools_Cache_Nil;
end
end
function DevTools_RunDump(value, context)
local prefix = "";
local firstPrefix = prefix;
local valType = type(value);
if (type(value) == 'table') then
local any =
DevTools_DumpTableContents(value, prefix, firstPrefix, context);
if (context.Result) then
return context:Result();
end
if (not any) then
context:Write("empty result");
end
return;
end
DevTools_DumpValue(value, '', '', '', context);
if (context.Result) then
return context:Result();
end
end
-- Dump the specified list of value
function DevTools_Dump(value, startKey)
local context = {
depth = 0,
key = startKey,
};
context.GetTableName = Pick_Cache_Function(DevTools_Cache_Table, DEVTOOLS_USE_TABLE_CACHE);
context.GetFunctionName = Pick_Cache_Function(DevTools_Cache_Function, DEVTOOLS_USE_FUNCTION_CACHE);
context.GetUserdataName = Pick_Cache_Function(DevTools_Cache_Userdata, DEVTOOLS_USE_USERDATA_CACHE);
context.Write = DevTools_Write;
DevTools_RunDump(value, context);
end
function DevTools_DumpCommand(msg, editBox)
if (string_match(msg,"^[A-Za-z_][A-Za-z0-9_]*$")) then
WriteMessage("Dump: " .. msg);
local val = _G[msg];
local tmp = {};
if (val == nil) then
local key = string_format(FORMATS.tableKeyAssignPrefix, '', prepSimpleKey(msg, {}));
WriteMessage(key .. "nil,");
else
tmp[msg] = val;
end
DevTools_Dump(tmp);
return;
end
WriteMessage("Dump: value=" .. msg);
local func,err = loadstring("return " .. msg);
if (not func) then
WriteMessage("Dump: ERROR: " .. err);
else
DevTools_Dump({func()}, "value");
end
end
DT.functionSymbols = {};
DT.userdataSymbols = {};
local funcSyms = DT.functionSymbols;
local userSyms = DT.userdataSymbols;
for k,v in pairs(getfenv(0)) do
if (type(v) == 'function') then
table.insert(funcSyms, k);
elseif (type(v) == 'table') then
if (type(rawget(v,0)) == 'userdata') then
table.insert(userSyms, k);
end
end
end
Binary file not shown.