This commit is contained in:
Bunny67
2017-12-11 20:27:02 +03:00
commit de8c95c8f0
295 changed files with 57024 additions and 0 deletions
@@ -0,0 +1,7 @@
## Interface: 11200
## Title: !Compatibility
## Notes: Compatibility functions for Vanilla
## Version: 1.0
api\api.xml
debugTools.lua
+4
View File
@@ -0,0 +1,4 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="wowLua.lua"/>
<Script file="wowAPI.lua"/>
</Ui>
+103
View File
@@ -0,0 +1,103 @@
--Cache global variables
local _G = getfenv()
local assert = assert
local error = error
local type = type
local unpack = unpack
local date = date
local gsub = string.gsub
function hooksecurefunc(arg1, arg2, arg3)
if type(arg1) == "string" then
arg1, arg2, arg3 = _G, arg1, arg2
end
local orig = arg1[arg2]
if type(orig) ~= "function" then
error("The function "..arg2.." does not exist", 2)
end
arg1[arg2] = function(...)
local tmp = {orig(unpack(arg))}
arg3(unpack(arg))
return unpack(tmp)
end
end
local function noop() end
function HookScript(frame, method, func)
assert(frame, "HookScript: frame argument missing")
local orig = frame:GetScript(method) or noop
frame:SetScript(method, function(...)
local tmp = {orig(unpack(arg))}
func(unpack(arg))
return unpack(tmp)
end)
end
function BetterDate(formatString, timeVal)
local dateTable = date("*t", timeVal)
local amString = (dateTable.hour >= 12) and "PM" or "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
RAID_CLASS_COLORS = {
["HUNTER"] = {r = 0.67, g = 0.83, b = 0.45},
["WARLOCK"] = {r = 0.58, g = 0.51, b = 0.79},
["PRIEST"] = {r = 1.0, g = 1.0, b = 1.0},
["PALADIN"] = {r = 0.96, g = 0.55, b = 0.73},
["MAGE"] = {r = 0.41, g = 0.8, b = 0.94},
["ROGUE"] = {r = 1.0, g = 0.96, b = 0.41},
["DRUID"] = {r = 1.0, g = 0.49, b = 0.04},
["WARRIOR"] = {r = 0.78, g = 0.61, b = 0.43},
};
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 GetQuestDifficultyColor(level)
local levelDiff = level - UnitLevel("player")
local color
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 EasyMenu(menuList, menuFrame, anchor, x, y, displayMode, autoHideDelay)
if displayMode == "MENU" then
menuFrame.displayMode = displayMode
end
UIDropDownMenu_Initialize(menuFrame, EasyMenu_Initialize, displayMode)
ToggleDropDownMenu(1, nil, menuFrame, anchor, x, y, menuList)
end
function EasyMenu_Initialize()
print(level, info)
for index = 1, getn(menuList) do
local value = menuList[index]
if value.text then
value.index = index;
UIDropDownMenu_AddButton(value, level)
end
end
end
+142
View File
@@ -0,0 +1,142 @@
--Cache global variables
local assert = assert
local error = error
local geterrorhandler = geterrorhandler
local pairs = pairs
local pcall = pcall
local tostring = tostring
local type = type
local unpack = unpack
local ceil, floor = math.ceil, math.floor
local format, gsub = string.format, string.gsub
local getn, insert = table.getn, table.insert
function select(n, ...)
assert(type(n) == "number" or type(n) == "string", "bad argument #1 to 'select' (number expected, got no value)")
if type(n) == "string" and n == "#" then
if type(arg) == "table" then
return getn(arg)
else
return 1
end
end
local temp = {}
for i = n, getn(arg) do
insert(temp, arg[i])
end
return unpack(temp)
end
function math.modf(i)
assert(type(i) == "number", "bad argument #1 to 'modf' (number expected, got no value)")
local int = i >= 0 and floor(i) or ceil(i)
return int, i - int
end
function string.join(delimiter, ...)
-- assert(type(delimiter) == "number", "bad argument #1 to 'join' (string expected, got no value)")
local size = getn(arg)
if size == 0 then
return ""
end
local text = arg[1]
for i = 2, size do
text = text..delimiter..arg[i]
end
return text
end
strjoin = string.join
function string.split(delimiter, subject)
assert(type(delimiter) == "string", "bad argument #1 to 'split' (string expected, got no value)")
local delimiter, fields = delimiter or ":", {}
local pattern = format("([^%s]+)", delimiter)
gsub(subject, pattern, function(c) fields[getn(fields) + 1] = c end)
return unpack(fields)
end
strsplit = string.split
function table.wipe(t)
assert(type(t) == "table", "bad argument #1 to 'wipe' (table expected, got 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 = getn(arg)
-- Simple versions for common argument counts
if (n == 1) then
return tostring(arg[1])
elseif (n == 2) then
return tostring(arg[1]), tostring(arg[2])
elseif (n == 3) then
return tostring(arg[1]), tostring(arg[2]), tostring(arg[3])
elseif (n == 0) then
return
end
local needfix
for i = 1, n do
local v = arg[i]
if (type(v) ~= "string") then
needfix = i
break
end
end
if (not needfix) then return unpack(arg) end
wipe(LOCAL_ToStringAllTemp)
for i = 1, needfix - 1 do
LOCAL_ToStringAllTemp[i] = arg[i]
end
for i = needfix, n do
LOCAL_ToStringAllTemp[i] = tostring(arg[i])
end
return unpack(LOCAL_ToStringAllTemp)
end
local LOCAL_PrintHandler = function(...)
DEFAULT_CHAT_FRAME:AddMessage(strjoin(" ", tostringall(unpack(arg))))
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, unpack(arg))
if (not ok) then
local func = geterrorhandler()
func(err)
end
end
function print(...)
pcall(print_inner, unpack(arg))
end
SLASH_PRINT1 = "/print"
SlashCmdList["PRINT"] = print
+69
View File
@@ -0,0 +1,69 @@
--Cache global variables
local strmatch = strmatch
--WoW API
local GetCVar = GetCVar
local IsAddOnLoaded = IsAddOnLoaded
local LoadAddOn = LoadAddOn
local UIParentLoadAddOn = UIParentLoadAddOn
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
SLASH_FRAMESTACK1 = "/framestack"
SLASH_FRAMESTACK2 = "/fstack"
SlashCmdList["FRAMESTACK"] = function(msg)
UIParentLoadAddOn("!DebugTools")
FrameStackTooltip_Toggle(showHidden)
end
SLASH_EVENTTRACE1 = "/eventtrace"
SLASH_EVENTTRACE2 = "/etrace"
SlashCmdList["EVENTTRACE"] = function(msg)
UIParentLoadAddOn("!DebugTools")
EventTraceFrame_HandleSlashCmd(msg)
end
SLASH_DUMP1 = "/dump"
SlashCmdList["DUMP"] = function(msg)
UIParentLoadAddOn("!DebugTools")
DevTools_DumpCommand(msg)
end