This commit is contained in:
Bunny67
2017-12-16 20:54:30 +03:00
parent 15b978d2cb
commit 273a5e6832
9 changed files with 107 additions and 92 deletions
@@ -1,7 +1,7 @@
## Interface: 11200
## Title: !Compatibility
## Notes: Compatibility functions for Vanilla
## Version: 1.1
## Version: 1.0
errorHandler.lua
api\api.xml
+6 -6
View File
@@ -9,7 +9,7 @@ local type = type
local unpack = unpack
local ceil, floor = math.ceil, math.floor
local find, format, gsub, sub = string.find, string.format, string.gsub, string.sub
local getn, insert = table.getn, table.insert
local getn, tinsert = table.getn, table.insert
math.huge = 1/0
string.gmatch = string.gfind
@@ -22,9 +22,9 @@ function difftime(time2, time1)
end
function select(n, ...)
assert(type(n) == "number" or type(n) == "string", format("bad argument #1 to 'select' (number expected, got %s)", n and type(n) or "no value"))
assert(type(n) == "number" or (type(n) == "string" and n == "#"), format("bad argument #1 to 'select' (number expected, got %s)", n and type(n) or "no value"))
if type(n) == "string" and n == "#" then
if type(n) == "string" then
if type(arg) == "table" then
return getn(arg)
else
@@ -35,7 +35,7 @@ function select(n, ...)
local temp = {}
for i = n, getn(arg) do
insert(temp, arg[i])
tinsert(temp, arg[i])
end
return unpack(temp)
@@ -71,9 +71,9 @@ function string.match(str, pattern, index)
assert(type(pattern) == "string", format("bad argument #2 to 'match' (string expected, got %s)", pattern and type(pattern) or "no value"))
str = type(str) == "number" and tostring(str) or str
local _, _, match = find(index and sub(str, index) or str, "("..pattern..")")
local i, j = find(index and sub(str, index) or str, pattern)
return match
return i and sub(str, i, j)
end
strmatch = string.match
+22 -12
View File
@@ -3,6 +3,7 @@ local _G = _G
local assert = assert
local date = date
local pairs = pairs
local select = select
local tonumber = tonumber
local type = type
local unpack = unpack
@@ -94,15 +95,15 @@ function hooksecurefunc(arg1, arg2, arg3)
end
end
--[[ issecurevariable
--[[ issecurevariable([table], variable)
Returns 1, nil for undefined variables. This is because an undefined variable is secure since you have not tainted it.
Returns 1, nil for all untainted variables (i.e. Blizzard variables).
Returns nil for any global variable that is hooked insecurely (tainted), even unprotected ones like UnitName().
Returns nil for all user defined global variables.
If a table is passed first, it checks table.variable (e.g. issecurevariable(PlayerFrame, "Show") checks PlayerFrame["Show"] or PlayerFrame.Show (they are the same thing)).
]]
function issecurevariable(tab, var)
-- assert(type(tab) == "table" and type(var) == "string", "Usage: issecurevariable([table,] \"variable\")")
function issecurevariable(t, var)
-- assert(type(t) == "table" and type(var) == "string", "Usage: issecurevariable([table,] \"variable\")")
return
end
@@ -232,11 +233,7 @@ 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
return zoneInfo[zoneName] and zoneInfo[zoneName].mapID or 0
end
function GetMapNameByID(id)
@@ -280,7 +277,7 @@ local function OnOrientationChanged(self, orientation)
end
local function OnSizeChanged()
local width, height = ElvUF_Player.Health:GetWidth(), ElvUF_Player.Health:GetHeight()
local width, height = this:GetWidth(), this:GetHeight()
this.texturePointer.width = width
this.texturePointer.height = height
this.texturePointer:SetWidth(width)
@@ -288,11 +285,13 @@ local function OnSizeChanged()
end
local function OnValueChanged()
local value = arg1
local _, max = this:GetMinMaxValues()
if this.texturePointer.verticalOrientation then
this.texturePointer:SetHeight(this.texturePointer.height * (arg1 / max))
this.texturePointer:SetHeight(this.texturePointer.height * (value / max))
else
this.texturePointer:SetWidth(this.texturePointer.width * (arg1 / max))
this.texturePointer:SetWidth(this.texturePointer.width * (value / max))
end
end
@@ -342,7 +341,6 @@ 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
@@ -358,3 +356,15 @@ function GetThreatStatus(currentThreat, maxThreat)
return 0, threatPercent
end
end
-- Credits: @Shagu - pfUI
-- https://github.com/shagu/pfUI/blob/7999f612ad464261306bbf6f309bb63b54bd44af/api/api.lua#L123
function GetItemLinkByName(name)
for itemID = 1, 25818 do
local itemName, itemLink, itemQuality = GetItemInfo(itemID)
if itemName and itemName == name then
local hex = select(4, GetItemQualityColor(tonumber(itemQuality)))
return hex.. "|H"..itemLink.."|h["..itemName.."]|h|r"
end
end
end
+10 -2
View File
@@ -1,16 +1,18 @@
--Cache global variables
local strmatch = strmatch
--WoW API
local IsAddOnLoaded = IsAddOnLoaded
local checked
local function LoadDebugTools()
if checked then return end
local _, _, _, lod, _, reason = GetAddOnInfo("!DebugTools")
local _, _, _, loadable, _, reason = GetAddOnInfo("!DebugTools")
checked = true
if reason == "MISSING" then return end
if lod then
if loadable then
LoadAddOn("!DebugTools")
else
EnableAddOn("!DebugTools")
@@ -41,11 +43,17 @@ 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
@@ -106,12 +106,12 @@ function EventTraceFrame_OnEvent (self, event, ...)
self.framesSinceLast[nextIndex] = 0;
self.eventids[nextIndex] = GetCurrentEventID();
local numArgs = select("#", arg);
local numArgs = select("#", unpack(arg));
for i=1, numArgs do
if (not self.args[i]) then
self.args[i] = {};
end
self.args[i][nextIndex] = select(i, arg);
self.args[i][nextIndex] = arg[i];
end
if (self.eventsToCapture) then
@@ -135,7 +135,7 @@ function EventTraceFrame_OnShow(self)
scrollBar:SetValue(maxValue);
end
function EventTraceFrame_OnUpdate ()
function EventTraceFrame_OnUpdate (self, elapsed)
EventTraceFrame_Update();
end
@@ -528,7 +528,7 @@ function ScriptErrorsFrame_OnLoad (self)
_ScriptErrorsFrame = self;
end
function ScriptErrorsFrame_OnShow ()
function ScriptErrorsFrame_OnShow (self)
ScriptErrorsFrame_Update();
end
@@ -669,7 +669,7 @@ function FrameStackTooltip_OnLoad(self)
self:RegisterEvent("DISPLAY_SIZE_CHANGED")
end
function FrameStackTooltip_OnEvent(self, event)
function FrameStackTooltip_OnEvent(self, event, ...)
if (event == "DISPLAY_SIZE_CHANGED") then
FrameStackTooltip_OnDisplaySizeChanged(self)
end
@@ -375,7 +375,7 @@
EventTraceFrame_OnShow(this);
</OnShow>
<OnEvent>
EventTraceFrame_OnEvent(this, event, arg);
EventTraceFrame_OnEvent(this, event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15);
</OnEvent>
<OnUpdate>
EventTraceFrame_OnUpdate(this, arg1);
+2 -5
View File
@@ -3,7 +3,7 @@ local mod = math.mod
local pairs = pairs
local tostring = tostring
local format, match = string.format, string.match
local getn, tinsert, tsort, twipe = table.getn, table.insert, table.sort, table.wipe
local getn, setn, tinsert, tsort, twipe = table.getn, table.setn, table.insert, table.sort, table.wipe
-- WoW API
local GetTime = GetTime
@@ -86,11 +86,7 @@ local function FrameStackSort(b, a)
return
end
if a and b then
return a < b
else
return
end
end
function UpdateFrameStack(tooltip, showHidden)
@@ -99,6 +95,7 @@ function UpdateFrameStack(tooltip, showHidden)
for i = 1, getn(frameStackList) do
frameStackList[i] = nil
end
setn(frameStackList, 0)
for k in pairs(frameStackLevels) do
frameStackLevels[k] = nil