mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 16:34:45 +00:00
remove temp folder structure
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/">
|
||||
<Script file="luaAPI.lua"/>
|
||||
<Include file="..\libs\libs.xml"/>
|
||||
<Script file="wowAPI.lua"/>
|
||||
</Ui>
|
||||
@@ -0,0 +1,278 @@
|
||||
--Cache global variables
|
||||
--local assert = assert
|
||||
local error = error
|
||||
local geterrorhandler = geterrorhandler
|
||||
local loadstring = loadstring
|
||||
local pairs = pairs
|
||||
local pcall = pcall
|
||||
local tostring = tostring
|
||||
local type = type
|
||||
local unpack = unpack
|
||||
local ceil, floor = math.ceil, math.floor
|
||||
local find, format, gfind, gsub, sub = string.find, string.format, string.gfind, string.gsub, string.sub
|
||||
local concat, getn, setn, tinsert = table.concat, table.getn, table.setn, table.insert
|
||||
|
||||
local escapeSequences = {
|
||||
["\a"] = "\\a", -- Bell
|
||||
["\b"] = "\\b", -- Backspace
|
||||
["\t"] = "\\t", -- Horizontal tab
|
||||
["\n"] = "\\n", -- Newline
|
||||
["\v"] = "\\v", -- Vertical tab
|
||||
["\f"] = "\\f", -- Form feed
|
||||
["\r"] = "\\r", -- Carriage return
|
||||
["\\"] = "\\\\", -- Backslash
|
||||
["\""] = "\\\"", -- Quotation mark
|
||||
["|"] = "||",
|
||||
[" "] = "%s",
|
||||
|
||||
[" "] = "%s",
|
||||
["!"] = "\\!",
|
||||
["#"] = "\\#",
|
||||
["$"] = "\\$",
|
||||
["%"] = "\\%",
|
||||
["&"] = "\\&",
|
||||
["'"] = "\\'",
|
||||
["("] = "\\(",
|
||||
[")"] = "\\)",
|
||||
["*"] = "\\*",
|
||||
["+"] = "\\+",
|
||||
[","] = "\\,",
|
||||
["-"] = "\\-",
|
||||
["."] = "\\.",
|
||||
["/"] = "\\/"
|
||||
}
|
||||
|
||||
math.huge = 1/0
|
||||
string.gmatch = gfind
|
||||
|
||||
function difftime(time2, time1)
|
||||
-- assert(type(time2) == "number", format("bad argument #1 to 'difftime' (number expected, got %s)", time2 and type(time2) or "no value"))
|
||||
-- assert(not time1 or type(time1) == "number", format("bad argument #2 to 'difftime' (number expected, got %s)", time1 and type(time1) or "no value"))
|
||||
if type(time2) ~= "number" then
|
||||
error(format("bad argument #1 to 'difftime' (number expected, got %s)", time2 and type(time2) or "no value"), 2)
|
||||
elseif time1 and type(time1) ~= "number" then
|
||||
error(format("bad argument #2 to 'difftime' (number expected, got %s)", time1 and type(time1) or "no value"), 2)
|
||||
end
|
||||
|
||||
return time1 and time2 - time1 or time2
|
||||
end
|
||||
|
||||
function select(n, ...)
|
||||
-- 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 not (type(n) == "number" or (type(n) == "string" and n == "#")) then
|
||||
error(format("bad argument #1 to 'select' (number expected, got %s)", n and type(n) or "no value"), 2)
|
||||
end
|
||||
|
||||
if type(n) == "string" then
|
||||
return getn(arg)
|
||||
end
|
||||
|
||||
if n == 1 then
|
||||
return unpack(arg)
|
||||
end
|
||||
|
||||
local args = {}
|
||||
|
||||
for i = n, getn(arg) do
|
||||
args[i-n+1] = arg[i]
|
||||
end
|
||||
|
||||
return unpack(args)
|
||||
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"))
|
||||
if type(i) ~= "number" then
|
||||
error(format("bad argument #1 to 'modf' (number expected, got %s)", i and type(i) or "no value"), 2)
|
||||
end
|
||||
|
||||
local int = i >= 0 and floor(i) or ceil(i)
|
||||
|
||||
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"))
|
||||
if type(delimiter) ~= "string" and type(delimiter) ~= "number" then
|
||||
error(format("bad argument #1 to 'join' (string expected, got %s)", delimiter and type(delimiter) or "no value"), 2)
|
||||
end
|
||||
|
||||
if getn(arg) == 0 then
|
||||
return ""
|
||||
end
|
||||
|
||||
return concat(arg, delimiter)
|
||||
end
|
||||
strjoin = string.join
|
||||
|
||||
function string.match(str, pattern, index)
|
||||
-- assert(type(str) == "string" or type(str) == "number", format("bad argument #1 to 'match' (string expected, got %s)", str and type(str) or "no value"))
|
||||
-- assert(type(pattern) == "string" or type(pattern) == "number", format("bad argument #2 to 'match' (string expected, got %s)", pattern and type(pattern) or "no value"))
|
||||
-- assert(not index or type(index) == "number" or (type(index) == "string" and index ~= ""), format("bad argument #3 to 'match' (number expected, got %s)", index and type(index) or "no value"))
|
||||
if type(str) ~= "string" and type(str) ~= "number" then
|
||||
error(format("bad argument #1 to 'match' (string expected, got %s)", str and type(str) or "no value"), 2)
|
||||
elseif type(pattern) ~= "string" and type(pattern) ~= "number" then
|
||||
error(format("bad argument #2 to 'match' (string expected, got %s)", pattern and type(pattern) or "no value"), 2)
|
||||
elseif index and type(index) ~= "number" and (type(index) ~= "string" or index == "") then
|
||||
error(format("bad argument #3 to 'match' (number expected, got %s)", index and type(index) or "no value"), 2)
|
||||
end
|
||||
|
||||
local i1, i2, match, match2 = find(str, pattern, index)
|
||||
|
||||
if not match and i2 and i2 >= i1 then
|
||||
return sub(str, i1, i2)
|
||||
elseif match2 then
|
||||
local matches = {find(str, pattern, index)}
|
||||
tremove(matches, 2)
|
||||
tremove(matches, 1)
|
||||
return unpack(matches)
|
||||
end
|
||||
|
||||
return match
|
||||
end
|
||||
strmatch = string.match
|
||||
|
||||
function string.split(delimiter, str)
|
||||
-- assert(type(delimiter) == "string" or type(delimiter) == "number", format("bad argument #1 to 'split' (string expected, got %s)", delimiter and type(delimiter) or "no value"))
|
||||
-- assert(type(str) == "string" or type(str) == "number", format("bad argument #2 to 'split' (string expected, got %s)", str and type(str) or "no value"))
|
||||
if type(delimiter) ~= "string" and type(delimiter) ~= "number" then
|
||||
error(format("bad argument #1 to 'split' (string expected, got %s)", delimiter and type(delimiter) or "no value"), 2)
|
||||
elseif type(str) ~= "string" and type(str) ~= "number" then
|
||||
error(format("bad argument #2 to 'split' (string expected, got %s)", str and type(str) or "no value"), 2)
|
||||
end
|
||||
|
||||
local fields = {}
|
||||
gsub(str, format("([^%s]+)", delimiter), function(c) fields[getn(fields) + 1] = c end)
|
||||
|
||||
return unpack(fields)
|
||||
end
|
||||
strsplit = string.split
|
||||
|
||||
function string.trim(str, chars)
|
||||
-- assert(type(str) == "string" or type(str) == "number", format("bad argument #1 to 'trim' (string expected, got %s)", str and type(str) or "no value"))
|
||||
-- assert(not chars or type(chars) == "string" or type(chars) == "number", format("bad argument #2 to 'trim' (string expected, got %s)", chars and type(chars) or "no value"))
|
||||
if type(str) ~= "string" and type(str) ~= "number" then
|
||||
error(format("bad argument #1 to 'trim' (string expected, got %s)", str and type(str) or "no value"), 2)
|
||||
elseif chars and (type(chars) ~= "string" and type(chars) ~= "number") then
|
||||
error(format("bad argument #2 to 'trim' (string expected, got %s)", chars and type(chars) or "no value"), 2)
|
||||
end
|
||||
|
||||
if chars then
|
||||
local tokens = {}
|
||||
|
||||
for token in gfind(chars, "[%z\1-\255]") do
|
||||
tinsert(tokens, token)
|
||||
end
|
||||
|
||||
local pattern = ""
|
||||
local size = getn(tokens)
|
||||
|
||||
for i = 1, size do
|
||||
pattern = pattern..(escapeSequences[tokens[i]] or tokens[i]).."+"
|
||||
|
||||
if i < size then
|
||||
pattern = pattern.."|"
|
||||
end
|
||||
end
|
||||
|
||||
local patternStart = loadstring("return \"^["..pattern.."](.-)$\"")()
|
||||
local patternEnd = loadstring("return \"^(.-)["..pattern.."]$\"")()
|
||||
|
||||
local trimed, x, y = 1
|
||||
while trimed > 0 do
|
||||
str, x = gsub(str, patternStart, "%1")
|
||||
str, y = gsub(str, patternEnd, "%1")
|
||||
trimed = x + y
|
||||
end
|
||||
|
||||
return str
|
||||
elseif type(str) == "string" then
|
||||
-- remove leading/trailing [space][tab][return][newline]
|
||||
return gsub(str, "^%s*(.-)%s*$", "%1")
|
||||
else
|
||||
return tostring(str)
|
||||
end
|
||||
end
|
||||
strtrim = string.trim
|
||||
|
||||
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"))
|
||||
if type(t) ~= "table" then
|
||||
error(format("bad argument #1 to 'wipe' (table expected, got %s)", t and type(t) or "no value"), 2)
|
||||
end
|
||||
|
||||
for k in pairs(t) do
|
||||
t[k] = nil
|
||||
end
|
||||
|
||||
if getn(t) ~= 0 then
|
||||
setn(t, 0)
|
||||
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 strjoin = strjoin
|
||||
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
|
||||
@@ -0,0 +1,411 @@
|
||||
--Cache global variables
|
||||
local _G = _G
|
||||
--local assert = assert
|
||||
local date = date
|
||||
local error = error
|
||||
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
|
||||
local GetItemInfo = GetItemInfo
|
||||
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 TIMEMANAGER_AM = gsub(TIME_TWELVEHOURAM, "^.-(%w+)$", "%1")
|
||||
local TIMEMANAGER_PM = gsub(TIME_TWELVEHOURPM, "^.-(%w+)$", "%1")
|
||||
--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 = getn(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 HookScript(frame, scriptType, handler)
|
||||
-- assert(type(frame) == "table" and frame.GetScript and type(scriptType) == "string" and type(handler) == "function", "Usage: HookScript(frame, \"type\", function)")
|
||||
if not (type(frame) == "table" and frame.GetScript and type(scriptType) == "string" and type(handler) == "function") then
|
||||
error("Usage: HookScript(frame, \"type\", function)", 2)
|
||||
end
|
||||
|
||||
local original_scipt = frame:GetScript(scriptType)
|
||||
if original_scipt then
|
||||
frame:SetScript(scriptType, function(...)
|
||||
local original_return = {original_scipt(unpack(arg))}
|
||||
handler(unpack(arg))
|
||||
|
||||
return unpack(original_return)
|
||||
end)
|
||||
else
|
||||
frame:SetScript(scriptType, handler)
|
||||
end
|
||||
end
|
||||
|
||||
function hooksecurefunc(arg1, arg2, arg3)
|
||||
local isMethod = type(arg1) == "table" and type(arg2) == "string" and type(arg1[arg2]) == "function" and type(arg3) == "function"
|
||||
-- assert(isMethod or (type(arg1) == "string" and type(_G[arg1]) == "function" and type(arg2) == "function"), "Usage: hooksecurefunc([table,] \"functionName\", hookfunc)")
|
||||
if not (isMethod or (type(arg1) == "string" and type(_G[arg1]) == "function" and type(arg2) == "function")) then
|
||||
error("Usage: hooksecurefunc([table,] \"functionName\", hookfunc)", 2)
|
||||
end
|
||||
|
||||
if not isMethod then
|
||||
arg1, arg2, arg3 = _G, arg1, arg2
|
||||
end
|
||||
|
||||
local original_func = arg1[arg2]
|
||||
|
||||
arg1[arg2] = function(...)
|
||||
local original_return = {original_func(unpack(arg))}
|
||||
arg3(unpack(arg))
|
||||
|
||||
return unpack(original_return)
|
||||
end
|
||||
end
|
||||
|
||||
--[[ 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(t, var)
|
||||
-- assert(type(t) == "table" and type(var) == "string", "Usage: issecurevariable([table,] \"variable\")")
|
||||
return
|
||||
end
|
||||
|
||||
function tContains(table, item)
|
||||
local index = 1
|
||||
|
||||
while table[index] do
|
||||
if item == table[index] then
|
||||
return 1
|
||||
end
|
||||
index = index + 1
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
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 ((type(unit) == "string" or type(unit) == "number") and (type(i) == "string" or type(i) == "number")) then
|
||||
error("Usage: UnitAura(\"unit\", index [, filter])", 2)
|
||||
end
|
||||
|
||||
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 "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
|
||||
|
||||
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])")
|
||||
if type(tab) ~= "table" then
|
||||
error("Usage: FillLocalizedClassList(classTable[, isFemale])", 2)
|
||||
end
|
||||
|
||||
for _, engClass in ipairs(CLASS_SORT_ORDER) do
|
||||
if female then
|
||||
tab[engClass] = LBC[engClass]
|
||||
else
|
||||
tab[engClass] = LBC[gsub(lower(engClass), "^%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},
|
||||
|
||||
-- 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},
|
||||
}
|
||||
|
||||
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 = 1
|
||||
local difficultyName = DUNGEON_DIFFICULTY1
|
||||
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()
|
||||
|
||||
return zoneInfo[zoneName] and zoneInfo[zoneName].mapID or 0
|
||||
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"))
|
||||
if not (type(id) == "string" or type(id) == "number") then
|
||||
error(format("Bad argument #1 to \"GetMapNameByID\" (number expected, got %s)", id and type(id) or "no value"), 2)
|
||||
end
|
||||
|
||||
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()
|
||||
local width, height = this:GetWidth(), this:GetHeight()
|
||||
this.texturePointer.width = width
|
||||
this.texturePointer.height = height
|
||||
this.texturePointer:SetWidth(width)
|
||||
this.texturePointer:SetHeight(height)
|
||||
end
|
||||
|
||||
local function OnValueChanged()
|
||||
local value = arg1
|
||||
local _, max = this:GetMinMaxValues()
|
||||
|
||||
if this.texturePointer.verticalOrientation then
|
||||
this.texturePointer:SetHeight(this.texturePointer.height * (value / max))
|
||||
else
|
||||
this.texturePointer:SetWidth(this.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)")
|
||||
if type(statusbar) ~= "table" then
|
||||
error(format("Bad argument #1 to \"CreateStatusBarTexturePointer\" (table expected, got %s)", statusbar and type(statusbar) or "no value"), 2)
|
||||
elseif not (statusbar.GetObjectType and statusbar:GetObjectType() == "StatusBar") then
|
||||
error("Bad argument #1 to \"CreateStatusBarTexturePointer\" (statusbar object expected)", 2)
|
||||
end
|
||||
|
||||
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 type(currentThreat) ~= "number" or type(maxThreat) ~= "number" then
|
||||
error("Usage: GetThreatStatus(currentThreat, maxThreat)", 2)
|
||||
end
|
||||
|
||||
if not maxThreat or maxThreat == 0 then
|
||||
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
|
||||
|
||||
local MAX_ITEM_ID = 24283
|
||||
local ItemInfoDB = {}
|
||||
|
||||
function GetItemInfoByName(name)
|
||||
-- assert(type(itemName) == "string", "Usage: GetItemInfoByName(itemName)")
|
||||
if type(name) ~= "string" then
|
||||
error("Usage: GetItemInfoByName(itemName)", 2)
|
||||
end
|
||||
|
||||
if not ItemInfoDB[name] then
|
||||
local itemName
|
||||
for itemID = 1, MAX_ITEM_ID do
|
||||
itemName = GetItemInfo(itemID)
|
||||
if itemName ~= "" then
|
||||
ItemInfoDB[name] = itemID
|
||||
|
||||
if name == itemName then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not ItemInfoDB[name] then return end
|
||||
|
||||
return GetItemInfo(ItemInfoDB[name])
|
||||
end
|
||||
Reference in New Issue
Block a user