mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 16:34:45 +00:00
2
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/">
|
||||
<Script file="luaAPI.lua"/>
|
||||
<Include file="..\libs\libs.xml"/>
|
||||
<Include file="..\libs\libs.xml"/>
|
||||
<Script file="wowAPI.lua"/>
|
||||
</Ui>
|
||||
@@ -1,4 +1,4 @@
|
||||
-- Cache global variables
|
||||
--Cache global variables
|
||||
local assert = assert
|
||||
local error = error
|
||||
local geterrorhandler = geterrorhandler
|
||||
@@ -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)
|
||||
@@ -44,25 +44,25 @@ end
|
||||
function math.modf(i)
|
||||
assert(type(i) == "number", format("bad argument #1 to 'modf' (number expected, got %s)", i and type(i) or "no value"))
|
||||
|
||||
local int = i >= 0 and floor(i) or ceil(i)
|
||||
local int = i >= 0 and floor(i) or ceil(i)
|
||||
|
||||
return int, i - int
|
||||
return int, i - int
|
||||
end
|
||||
|
||||
function string.join(delimiter, ...)
|
||||
assert(type(delimiter) == "string" or type(delimiter) == "number", format("bad argument #1 to 'join' (string expected, got %s)", delimiter and type(delimiter) or "no value"))
|
||||
|
||||
local size = getn(arg)
|
||||
if size == 0 then
|
||||
return ""
|
||||
end
|
||||
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
|
||||
local text = arg[1]
|
||||
for i = 2, size do
|
||||
text = text..delimiter..arg[i]
|
||||
end
|
||||
|
||||
return text
|
||||
return text
|
||||
end
|
||||
strjoin = string.join
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -139,36 +139,36 @@ 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 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
|
||||
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)
|
||||
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(...)
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
-- Cache global variables
|
||||
--Cache global variables
|
||||
local _G = _G
|
||||
local assert = assert
|
||||
local date = date
|
||||
local pairs = pairs
|
||||
local select = select
|
||||
local tonumber = tonumber
|
||||
local type = type
|
||||
local unpack = unpack
|
||||
local format, gsub, lower, match, upper = string.format, string.gsub, string.lower, string.match, string.upper
|
||||
local getn = table.getn
|
||||
-- WoW API
|
||||
--WoW API
|
||||
local GetQuestGreenRange = GetQuestGreenRange
|
||||
local GetRealZoneText = GetRealZoneText
|
||||
local IsInInstance = IsInInstance
|
||||
local UnitBuff = UnitBuff
|
||||
local UnitDebuff = UnitDebuff
|
||||
local UnitLevel = UnitLevel
|
||||
-- WoW Variables
|
||||
--WoW Variables
|
||||
local DUNGEON_DIFFICULTY1 = DUNGEON_DIFFICULTY1
|
||||
local TIMEMANAGER_AM = gsub(TIME_TWELVEHOURAM, "^.-(%w+)$", "%1")
|
||||
local TIMEMANAGER_PM = gsub(TIME_TWELVEHOURPM, "^.-(%w+)$", "%1")
|
||||
-- Libs
|
||||
--Libs
|
||||
local LBC = LibStub("LibBabble-Class-3.0"):GetLookupTable()
|
||||
local LBZ = LibStub("LibBabble-Zone-3.0"):GetLookupTable()
|
||||
|
||||
@@ -94,15 +95,15 @@ function hooksecurefunc(arg1, arg2, arg3)
|
||||
end
|
||||
end
|
||||
|
||||
--[[ issecurevariable
|
||||
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)).
|
||||
--[[ 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
|
||||
|
||||
@@ -357,4 +355,16 @@ function GetThreatStatus(currentThreat, maxThreat)
|
||||
else
|
||||
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
|
||||
Reference in New Issue
Block a user