-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add !Compatibility addoAdd !Compatibility addonn
- Loading branch information
1 parent
3cc2350
commit 72c5a6c
Showing
13 changed files
with
3,416 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## Interface: 20400 | ||
## Title: !Compatibility | ||
## Notes: Compatibility functions for TBC | ||
## Version: 1.0 | ||
|
||
errorHandler.lua | ||
api\api.xml | ||
slashCommands.lua |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.