Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Crum
2018-07-17 16:09:04 -05:00
13 changed files with 620 additions and 507 deletions
+47 -15
View File
@@ -2,6 +2,7 @@
local error = error local error = error
local geterrorhandler = geterrorhandler local geterrorhandler = geterrorhandler
local loadstring = loadstring local loadstring = loadstring
local next = next
local pairs = pairs local pairs = pairs
local pcall = pcall local pcall = pcall
local tonumber = tonumber local tonumber = tonumber
@@ -10,21 +11,12 @@ local type = type
local unpack = unpack local unpack = unpack
local abs, ceil, exp, floor = math.abs, math.ceil, math.exp, math.floor local abs, ceil, exp, floor = math.abs, math.ceil, math.exp, math.floor
local find, format, gfind, gsub, len, sub = string.find, string.format, string.gfind, string.gsub, string.len, string.sub local find, format, gfind, gsub, len, sub = string.find, string.format, string.gfind, string.gsub, string.len, string.sub
local concat, tinsert, getn, setn = table.concat, table.insert, table.getn, table.setn local concat, getn, setn, tremove = table.concat, table.getn, table.setn, table.remove
math.fmod = math.mod math.fmod = math.mod
math.huge = 1/0 math.huge = 1/0
string.gmatch = string.gfind string.gmatch = string.gfind
gmatch = string.gfind
function difftime(time2, time1)
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, ...) function select(n, ...)
if not (type(n) == "number" or (type(n) == "string" and n == "#")) then if not (type(n) == "number" or (type(n) == "string" and n == "#")) then
@@ -231,6 +223,7 @@ function string.reverse(str)
return str return str
end end
strrev = string.reverse
function string.split(delimiter, str) function string.split(delimiter, str)
if type(delimiter) ~= "string" and type(delimiter) ~= "number" then if type(delimiter) ~= "string" and type(delimiter) ~= "number" then
@@ -240,7 +233,7 @@ function string.split(delimiter, str)
end end
local fields = {} local fields = {}
gsub(str, format("([^%s]+)", delimiter), function(c) tinsert(fields, c) end) gsub(str, format("([^%s]+)", delimiter), function(c) fields[getn(fields) + 1] = c end)
return unpack(fields) return unpack(fields)
end end
@@ -303,10 +296,15 @@ function string.trim(str, chars)
local patternStart = loadstring("return \"^["..pattern.."](.-)$\"")() local patternStart = loadstring("return \"^["..pattern.."](.-)$\"")()
local patternEnd = loadstring("return \"^(.-)["..pattern.."]$\"")() local patternEnd = loadstring("return \"^(.-)["..pattern.."]$\"")()
local trimed, x, y = 1 local trimed, x, y = 1, 1, 1
while trimed > 0 do while trimed > 0 do
str, x = gsub(str, patternStart, "%1") if x > 0 then
str, y = gsub(str, patternEnd, "%1") str, x = gsub(str, patternStart, "%1")
end
if y > 0 then
str, y = gsub(str, patternEnd, "%1")
end
trimed = x + y trimed = x + y
end end
@@ -320,6 +318,40 @@ function string.trim(str, chars)
end end
strtrim = string.trim strtrim = string.trim
function strconcat(...)
if arg.n == 0 then
return ""
elseif arg.n == 1 then
return tostring(arg[1])
else
for i = 1, arg.n do
if type(arg[i]) ~= "string" then
error(format("attempt to concatenate a %s value", type(arg[i])), 2)
end
end
end
return concat(arg)
end
function table.maxn(t)
if type(t) ~= "table" then
error(format("bad argument #1 to 'maxn' (table expected, got %s)", t and type(t) or "no value"), 2)
end
local maxn = 0
local i = next(t, nil)
while i do
if type(i) == "number" and i > maxn then
maxn = i
end
i = next(t, i)
end
return maxn
end
function table.wipe(t) function table.wipe(t)
if type(t) ~= "table" then if type(t) ~= "table" then
error(format("bad argument #1 to 'wipe' (table expected, got %s)", t and type(t) or "no value"), 2) error(format("bad argument #1 to 'wipe' (table expected, got %s)", t and type(t) or "no value"), 2)
+91 -44
View File
@@ -7,9 +7,13 @@ local select = select
local tonumber = tonumber local tonumber = tonumber
local type = type local type = type
local unpack = unpack local unpack = unpack
local find, format, gsub, lower, match, upper = string.find, string.format, string.gsub, string.lower, string.match, string.upper local find, format, gmatch, gsub, lower, match, upper = string.find, string.format, string.gmatch, string.gsub, string.lower, string.match, string.upper
local getn = table.getn local getn = table.getn
--WoW API --WoW API
local debugstack = debugstack
local GetContainerItemInfo = GetContainerItemInfo
local GetContainerItemLink = GetContainerItemLink
local GetContainerNumSlots = GetContainerNumSlots
local GetInventoryItemTexture = GetInventoryItemTexture local GetInventoryItemTexture = GetInventoryItemTexture
local GetItemInfo = GetItemInfo local GetItemInfo = GetItemInfo
local GetQuestGreenRange = GetQuestGreenRange local GetQuestGreenRange = GetQuestGreenRange
@@ -20,12 +24,14 @@ local IsInInstance = IsInInstance
local UnitLevel = UnitLevel local UnitLevel = UnitLevel
--WoW Variables --WoW Variables
local DUNGEON_DIFFICULTY1 = DUNGEON_DIFFICULTY1 local DUNGEON_DIFFICULTY1 = DUNGEON_DIFFICULTY1
local DURABILITY_TEMPLATE = gsub(DURABILITY_TEMPLATE, "%%d / %%d", "(%%d+) / (%%d+)")
local NUM_BAG_FRAMES = NUM_BAG_FRAMES
local TIMEMANAGER_AM = gsub(TIME_TWELVEHOURAM, "^.-(%w+)$", "%1") local TIMEMANAGER_AM = gsub(TIME_TWELVEHOURAM, "^.-(%w+)$", "%1")
local TIMEMANAGER_PM = gsub(TIME_TWELVEHOURPM, "^.-(%w+)$", "%1") local TIMEMANAGER_PM = gsub(TIME_TWELVEHOURPM, "^.-(%w+)$", "%1")
local DURABILITY_TEMPLATE = gsub(DURABILITY_TEMPLATE, "%%d / %%d", "(%%d+) / (%%d+)")
--Libs --Libs
local LBC = LibStub("LibBabble-Class-3.0"):GetLookupTable() local LBC = LibStub("LibBabble-Class-3.0"):GetLookupTable()
local LBZ = LibStub("LibBabble-Zone-3.0"):GetLookupTable() local LBZ = LibStub("LibBabble-Zone-3.0"):GetLookupTable()
local IFDB = LibStub("ItemFamilyDB")
CLASS_SORT_ORDER = { CLASS_SORT_ORDER = {
"WARRIOR", "WARRIOR",
@@ -114,6 +120,31 @@ function hooksecurefunc(a1, a2, a3)
end end
end end
local secureFuncs = {
CameraOrSelectOrMoveStop = true,
MoveBackwardStop = true,
MoveForwardStop = true,
PitchDownStop = true,
PitchUpStop = true,
StrafeLeftStart = true,
StrafeRightStart = true,
ToggleMouseMove = true,
TurnLeftStart = true,
TurnOrActionStop = true,
TurnRightStart = true,
CameraOrSelectOrMoveStart = true,
Jump = true,
MoveBackwardStart = true,
MoveForwardStart = true,
PitchDownStart = true,
PitchUpStart = true,
StrafeLeftStop = true,
StrafeRightStop = true,
ToggleRun = true,
TurnLeftStop = true,
TurnOrActionStart = true,
TurnRightStop = true
}
--[[ issecurevariable([table], variable) --[[ 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 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 1, nil for all untainted variables (i.e. Blizzard variables).
@@ -125,7 +156,18 @@ function issecurevariable(t, var)
-- if type(var) ~= "table" or type(var) ~= "string" then -- if type(var) ~= "table" or type(var) ~= "string" then
-- error("Usage: issecurevariable([table,] \"variable\")", 2) -- error("Usage: issecurevariable([table,] \"variable\")", 2)
-- end -- end
return
local isSecure = secureFuncs[t] and 1 or nil
if not isSecure then
return
end
local taint
for x in gmatch(debugstack(), "\\AddOns\\(.-)\\") do
taint = x
end
return isSecure, taint
end end
function tContains(table, item) function tContains(table, item)
@@ -155,6 +197,16 @@ function UnitAura(unit, i, filter)
end end
end end
function difftime(time2, time1)
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 BetterDate(formatString, timeVal) function BetterDate(formatString, timeVal)
local dateTable = date("*t", timeVal) local dateTable = date("*t", timeVal)
local amString = (dateTable.hour >= 12) and "PM" or "AM" local amString = (dateTable.hour >= 12) and "PM" or "AM"
@@ -265,29 +317,6 @@ function GetMapNameByID(id)
return mapByID[tonumber(id)] return mapByID[tonumber(id)]
end end
local LBIBF = LibStub("LibBabble-ItemBagFamily-3.0")
function GetItemFamily(id)
if not id then return end
if type(id) == "table" or type(id) == "function" then return end
if type(id) == "string" then
id = tonumber(match(id, "item:(%d+)"))
end
return LBIBF.ItemFamily[id] or 0
end
function GetBagFamily(id)
if not id then return end
if type(id) == "table" or type(id) == "function" then return end
if type(id) == "string" then
id = tonumber(match(id, "item:(%d+)"))
end
return LBIBF.ItemBagFamily[id] or 0
end
local arrow local arrow
function GetPlayerFacing() function GetPlayerFacing()
if not arrow then if not arrow then
@@ -417,6 +446,7 @@ function GetItemInfoByName(itemName)
end end
if find(itemName, " of ") then if find(itemName, " of ") then
-- random enchantments
itemName = gsub(itemName, " of Spirit", "") itemName = gsub(itemName, " of Spirit", "")
itemName = gsub(itemName, " of Intellect", "") itemName = gsub(itemName, " of Intellect", "")
itemName = gsub(itemName, " of Strength", "") itemName = gsub(itemName, " of Strength", "")
@@ -461,7 +491,7 @@ function GetItemInfoByName(itemName)
for itemID = 1, LAST_ITEM_ID do for itemID = 1, LAST_ITEM_ID do
name = GetItemInfo(itemID) name = GetItemInfo(itemID)
if name ~= "" and name ~= nil then if name ~= nil and name ~= "" then
itemInfoDB[name] = itemID itemInfoDB[name] = itemID
if name == itemName then if name == itemName then
@@ -476,19 +506,36 @@ function GetItemInfoByName(itemName)
return GetItemInfo(itemInfoDB[itemName]) return GetItemInfo(itemInfoDB[itemName])
end end
function GetItemFamily(item, isBag)
if not item or type(item) ~= "number" or type(item) ~= "string" then return end
if type(item) == "string" then
local _, _, itemID = find(itemLink, "(%d+):")
if not itemID then return end
item = tonumber(itemID)
end
if item > LAST_ITEM_ID then return end
return (isBag and IFDB.ItemBagFamily[item] or IFDB.ItemFamily[item]) or 0
end
function GetItemCount(itemName) function GetItemCount(itemName)
if type(itemName) ~= "string" then return 0 end
local count = 0 local count = 0
for bag = NUM_BAG_FRAMES, 0, -1 do for bag = NUM_BAG_FRAMES, 0, -1 do
for slot = 1, GetContainerNumSlots(bag) do for slot = 1, GetContainerNumSlots(bag) do
local _, itemCount = GetContainerItemInfo(bag, slot) local _, itemCount = GetContainerItemInfo(bag, slot)
if itemCount then if itemCount then
local itemLink = GetContainerItemLink(bag, slot) local itemLink = GetContainerItemLink(bag, slot)
local _, _, itemParse = find(itemLink, "(%d+):") local _, _, itemID = find(itemLink, "(%d+):")
local queryName, _, _, _, _, _ = GetItemInfo(itemParse) local queryName = GetItemInfo(itemID)
if queryName and queryName ~= "" then
if queryName == itemName then if queryName and queryName == itemName then
count = count + itemCount count = count + itemCount
end
end end
end end
end end
@@ -497,22 +544,22 @@ function GetItemCount(itemName)
return count return count
end end
local scan local scanTooltip
function GetInventoryItemDurability(slot) function GetInventoryItemDurability(slot)
if not GetInventoryItemTexture("player", slot) then return nil, nil end if not GetInventoryItemTexture("player", slot) then return end
if not scan then if not scanTooltip then
scan = CreateFrame("GameTooltip", "DurabilityScan", nil, "ShoppingTooltipTemplate") scanTooltip = CreateFrame("GameTooltip", "Compatibility_ScanTooltip", nil, "ShoppingTooltipTemplate")
scan:SetOwner(UIParent, "ANCHOR_NONE") scanTooltip:SetOwner(UIParent, "ANCHOR_NONE")
end end
scan:ClearLines() scanTooltip:ClearLines()
scan:SetInventoryItem("player", slot) scanTooltip:SetInventoryItem("player", slot)
for i = 4, scan:NumLines() do for i = 4, scanTooltip:NumLines() do
local text = _G[scan:GetName().."TextLeft"..i]:GetText() local text = _G["Compatibility_ScanTooltipTextLeft"..i]:GetText()
for durability, max in string.gfind(text, DURABILITY_TEMPLATE) do for current, maximum in gmatch(text, DURABILITY_TEMPLATE) do
return tonumber(durability), tonumber(max) return tonumber(current), tonumber(maximum)
end end
end end
end end
@@ -1,30 +1,29 @@
local MAJOR_VERSION = "LibBabble-ItemBagFamily-3.0" local MAJOR_VERSION = "ItemFamilyDB"
local MINOR_VERSION = 90000 + tonumber(string.match("$Revision: 50 $", "%d+")) local MINOR_VERSION = 90000 + tonumber(string.match("$Revision: 1 $", "%d+"))
if not LibStub then error(MAJOR_VERSION .. " requires LibStub.") end local lib = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
local lib = LibStub("LibBabble-3.0"):New(MAJOR_VERSION, MINOR_VERSION)
if not lib then return end if not lib then return end
lib.ItemBagFamily = { lib.BagFamily = {
[8217] = 1,
[7371] = 1,
[7278] = 1,
[5439] = 1,
[3605] = 1,
[3573] = 1,
[2662] = 1,
[2101] = 1, [2101] = 1,
[19319] = 1, [2662] = 1,
[18714] = 1, [3573] = 1,
[3605] = 1,
[5439] = 1,
[7278] = 1,
[7371] = 1,
[8217] = 1,
[11362] = 1, [11362] = 1,
[8218] = 2, [18714] = 1,
[7372] = 2, [19319] = 1,
[7279] = 2,
[5441] = 2,
[3604] = 2,
[3574] = 2,
[2663] = 2,
[2102] = 2, [2102] = 2,
[2663] = 2,
[3574] = 2,
[3604] = 2,
[5441] = 2,
[7279] = 2,
[7372] = 2,
[8218] = 2,
[19320] = 2, [19320] = 2,
[21340] = 4, [21340] = 4,
[21341] = 4, [21341] = 4,
+1 -3
View File
@@ -7,10 +7,8 @@ Dependencies: None
License: MIT License: MIT
]] ]]
local match = string.match
local MAJOR_VERSION = "LibBabble-Zone-3.0" local MAJOR_VERSION = "LibBabble-Zone-3.0"
local MINOR_VERSION = 90000 + tonumber(match("$Revision: 107 $", "%d+")) local MINOR_VERSION = 90000 + tonumber(string.match("$Revision: 107 $", "%d+"))
if not LibStub then error(MAJOR_VERSION .. " requires LibStub.") end if not LibStub then error(MAJOR_VERSION .. " requires LibStub.") end
local lib = LibStub("LibBabble-3.0"):New(MAJOR_VERSION, MINOR_VERSION) local lib = LibStub("LibBabble-3.0"):New(MAJOR_VERSION, MINOR_VERSION)
+1 -1
View File
@@ -3,5 +3,5 @@
<Script file="LibBabble-3.0.lua"/> <Script file="LibBabble-3.0.lua"/>
<Script file="LibBabble-Class-3.0.lua"/> <Script file="LibBabble-Class-3.0.lua"/>
<Script file="LibBabble-Zone-3.0.lua"/> <Script file="LibBabble-Zone-3.0.lua"/>
<Script file="LibBabble-ItemBagFamily-3.0.lua"/> <Script file="ItemFamilyDB.lua"/>
</Ui> </Ui>
File diff suppressed because it is too large Load Diff
+5 -2
View File
@@ -436,11 +436,14 @@
<EditBox name="$parentText" multiLine="true" letters="4000" autoFocus="false"> <EditBox name="$parentText" multiLine="true" letters="4000" autoFocus="false">
<Size x="343" y="194"/> <Size x="343" y="194"/>
<Scripts> <Scripts>
<OnTextChanged>
ScrollingEdit_OnTextChanged(this:GetParent());
</OnTextChanged>
<OnCursorChanged> <OnCursorChanged>
ScrollingEdit_OnCursorChanged(this); ScrollingEdit_OnCursorChanged(arg1, arg2, arg3, arg4);
</OnCursorChanged> </OnCursorChanged>
<OnUpdate> <OnUpdate>
ScrollingEdit_OnUpdate(this, arg1, this:GetParent()); ScrollingEdit_OnUpdate(this:GetParent());
</OnUpdate> </OnUpdate>
<OnEditFocusGained> <OnEditFocusGained>
this:HighlightText(0); this:HighlightText(0);
-1
View File
@@ -7,7 +7,6 @@ local format = string.format
local GetTime = GetTime local GetTime = GetTime
--WoW API / Variables --WoW API / Variables
local CreateFrame = CreateFrame local CreateFrame = CreateFrame
local hooksecurefunc = hooksecurefunc
local ICON_SIZE = 36 --the normal size for an icon (don't change this) local ICON_SIZE = 36 --the normal size for an icon (don't change this)
local FONT_SIZE = 20 --the base font size to use at a scale of 1 local FONT_SIZE = 20 --the base font size to use at a scale of 1
-1
View File
@@ -14,7 +14,6 @@ local GameTooltip_Hide = GameTooltip_Hide
local GetBindingKey = GetBindingKey local GetBindingKey = GetBindingKey
local GetCurrentBindingSet = GetCurrentBindingSet local GetCurrentBindingSet = GetCurrentBindingSet
local GetMacroInfo = GetMacroInfo local GetMacroInfo = GetMacroInfo
local hooksecurefunc = hooksecurefunc
local IsAddOnLoaded = IsAddOnLoaded local IsAddOnLoaded = IsAddOnLoaded
local IsAltKeyDown = IsAltKeyDown local IsAltKeyDown = IsAltKeyDown
local IsControlKeyDown = IsControlKeyDown local IsControlKeyDown = IsControlKeyDown
+1 -1
View File
@@ -454,7 +454,7 @@ function B:Layout(isBank)
end end
f.Bags[bagID].numSlots = numSlots f.Bags[bagID].numSlots = numSlots
f.Bags[bagID].type = GetBagFamily(GetInventoryItemLink("player", ContainerIDToInventoryID(bagID))) f.Bags[bagID].type = GetItemFamily(GetInventoryItemLink("player", ContainerIDToInventoryID(bagID)), true)
--Hide unused slots --Hide unused slots
for i = 1, MAX_CONTAINER_ITEMS do for i = 1, MAX_CONTAINER_ITEMS do
+2 -2
View File
@@ -378,7 +378,7 @@ function B:IsSpecialtyBag(bagID)
local bag = GetInventoryItemLink("player", inventorySlot) local bag = GetInventoryItemLink("player", inventorySlot)
if not bag then return false end if not bag then return false end
local family = GetBagFamily(bag) local family = GetItemFamily(bag, true)
if family == 0 or family == nil then return false end if family == 0 or family == nil then return false end
return family return family
@@ -393,7 +393,7 @@ function B:CanItemGoInBag(bag, slot, targetBag)
itemFamily = 1 itemFamily = 1
end end
end end
local bagFamily = GetBagFamily(GetInventoryItemLink("player", ContainerIDToInventoryID(targetBag))) local bagFamily = GetItemFamily(GetInventoryItemLink("player", ContainerIDToInventoryID(targetBag)), true)
if itemFamily then if itemFamily then
return (bagFamily == 0) or band(itemFamily, bagFamily) > 0 return (bagFamily == 0) or band(itemFamily, bagFamily) > 0
else else
+17 -1
View File
@@ -42,16 +42,32 @@ function UF:Construct_PartyFrames()
return self; return self;
end end
function UF:PartySmartVisibility()
if not self then self = this end
if GetNumRaidMembers() < 1 then
self:Show()
else
self:Hide()
end
end
function UF:Update_PartyHeader(header) function UF:Update_PartyHeader(header)
if not header.positioned then if not header.positioned then
header:ClearAllPoints() header:ClearAllPoints()
header:SetPoint("BOTTOMLEFT", E.UIParent, "BOTTOMLEFT", 4, 195) header:SetPoint("BOTTOMLEFT", E.UIParent, "BOTTOMLEFT", 4, 195)
E:CreateMover(header, header:GetName().."Mover", L["Party Frames"], nil, nil, nil, "ALL,PARTY") E:CreateMover(header, header:GetName().."Mover", L["Party Frames"], nil, nil, nil, "ALL,PARTY")
header:RegisterEvent("PARTY_MEMBERS_CHANGED")
header:RegisterEvent("RAID_ROSTER_UPDATE")
header:SetScript("OnEvent", UF["PartySmartVisibility"])
header.positioned = true header.positioned = true
end end
end
UF.PartySmartVisibility(header)
end
function UF:Update_PartyFrames(frame, db) function UF:Update_PartyFrames(frame, db)
frame.db = db frame.db = db
+17
View File
@@ -42,14 +42,31 @@ function UF:Construct_RaidFrames()
return self return self
end end
function UF:RaidSmartVisibility()
if not self then self = this end
if GetNumRaidMembers() > 1 then
self:Show()
else
self:Hide()
end
end
function UF:Update_RaidHeader(header) function UF:Update_RaidHeader(header)
if not header.positioned then if not header.positioned then
header:ClearAllPoints() header:ClearAllPoints()
header:SetPoint("BOTTOMLEFT", E.UIParent, "BOTTOMLEFT", 4, 195) header:SetPoint("BOTTOMLEFT", E.UIParent, "BOTTOMLEFT", 4, 195)
E:CreateMover(header, header:GetName().."Mover", L["Raid Frames"], nil, nil, nil, "ALL,RAID") E:CreateMover(header, header:GetName().."Mover", L["Raid Frames"], nil, nil, nil, "ALL,RAID")
header:RegisterEvent("PARTY_MEMBERS_CHANGED")
header:RegisterEvent("RAID_ROSTER_UPDATE")
header:SetScript("OnEvent", UF["RaidSmartVisibility"])
header.positioned = true header.positioned = true
end end
UF.RaidSmartVisibility(header)
end end
function UF:Update_RaidFrames(frame, db) function UF:Update_RaidFrames(frame, db)