Commit f749fa22 authored by Azilroka's avatar Azilroka
Browse files

Merge branch 'development' into oUFNameplates

parent ba8acbe4
......@@ -4,12 +4,16 @@
Added new scale options. (/ec - General - Auto Scale | UI Scale)
Added quality border option for Bag/Bank items. (#869)
Added BoE/BoA text overlay in our Bag/Bank.
Added optional mount name for units on tooltips.
Added a new option to display Inspect Info on the Inspect and Character frames.
**Bug Fixes:**
Corrected more Pixel Perfect issues! :D
**Misc. Changes:**
Various Skin updates.
Modified the bag item level code; items might actually show the correct item level now. :o
Improved the tooltip item level code, it should be far more accurate now! (Thanks AcidWeb and Ls- for helping us with this!) :)
___
### Version 10.87 [ January 30th 2019 ]
......
......@@ -2,7 +2,6 @@ local MAJOR, MINOR = 'LibElvUIPlugin-1.0', 22
local lib, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
if not lib then return end
--Cache global variables
--Lua functions
local pairs, tonumber, strmatch, strsub = pairs, tonumber, strmatch, strsub
local format, strsplit, strlen, gsub, ceil = format, strsplit, strlen, gsub, ceil
......
--[[
type:
all - use sparingly because achivements look havy
items - returns a table of items
honor - not yet
talents - not yet
achivements - not yet
Methods:
success = LibInspect:AddHook('MyAddon', type, function(guid, data, age) YourFunction(guid, data, age); end);
maxAge = LibInspect:SetMaxAge(seconds);
recanQuantity = LibInspect:SetRescan(items);
caninspect, unitfound, refreshing = LibInspect:RequestData(type, target, force);
or LibInspect:Request_Type_(target, force)
ex. LibInspect:RequestItems(...)
Callbacks:
When the data is ready you YourFunction(guid, data, age) will be called
guid = UnitGUID(); use this to tie it to the inspect request
data = false or {
items = {
1 = itemLink,
2 = itemLink,
...
19 = itemLink,
},
honor = ...,
talents = {
id = ,
name = string,
description = string,
icon = image,
background = image,
role = role,
talents = {
1 = { -- see GetTalentInfo()
name = string,
iconTexture = image,
tier = int,
column = int,
selected = bool,
available = bool,
},
...
},
glyphs = {
1 = { -- see GetGlyphSocketInfo()
enabled = int,
glyphType = GLYPH_TYPE_MAJOR or GLYPH_TYPE_MINOR,
glyphTooltipIndex = ,
glyphSpell = spellId,
iconFilename = image or nil,
glyphID = ,
},
...
},
},
achivements = ...,
}
age = ##; how old in seconds the data is
]]
-- Start the lib
local lib = LibStub:NewLibrary('LibInspect', 5);
if not lib then return end
if not lib.frame then lib.frame = CreateFrame("Frame"); end
lib.maxAge = 1800; -- seconds
lib.rescan = 7; -- What to consider min items
lib.rescanGUID = {}; -- GUID for 2nd pass scanning
lib.cache = {};
lib.hooks = {
items = {},
honor = {},
talents = {},
achievemnts = {},
};
lib.events = {
items = "INSPECT_READY",
talents = "INSPECT_READY",
honor = "INSPECT_HONOR_UPDATE",
achievemnts = "INSPECT_ACHIEVEMENT_READY",
}
function lib:AddHook(addon, what, callback)
if addon and what and callback then
if type(what) == 'string' then
if what == 'all' then
local i = self:SecureAddHook(addon, 'items', callback);
local h = self:SecureAddHook(addon, 'honor', callback);
local t = self:SecureAddHook(addon, 'talents', callback);
local a = self:SecureAddHook(addon, 'achievemnts', callback);
if i and h and t and a then
return true;
else
return false, i, h, t, a;
end
elseif what == 'items' then
return self:SecureAddHook(addon, 'items', callback);
elseif what == 'honor' then
return self:SecureAddHook(addon, 'honor', callback);
elseif what == 'talents' then
return self:SecureAddHook(addon, 'talents', callback);
elseif what == 'achievemnts' then
return self:SecureAddHook(addon, 'achievemnts', callback);
else
--- print('LibInspect:AddHook Unkown Type '..what);
return false;
end
end
else
--- print('LibInspect:AddHook Missing Variable ', addon, what, callback);
return false;
end
end
-- Internal only, should prob be local
function lib:SecureAddHook(addon, what, callback)
if self.hooks[what] then
self.hooks[what][addon] = callback;
-- Register the event
if self.events[what] then
self.frame:RegisterEvent(self.events[what]);
end
return true;
else
--- print('LibInspect:SecureAddHook Unkown Type ', addon, what, callback);
return false;
end
end
function lib:RemoveHook(addon, what)
if addon then
if not what then what = 'all'; end
if what == 'all' then
self:RemoveHook(addon, 'items');
self:RemoveHook(addon, 'honor');
self:RemoveHook(addon, 'talents');
self:RemoveHook(addon, 'achievemnts');
elseif what == 'items' or what == 'honor' or what == 'talents' or what == 'achievemnts' then
self.hooks[what][addon] = false;
-- Clean up events if we can
if self:count(self.hooks[what]) == 0 and self.events[what] then
self.frame:UnregisterEvent(self.events[what]);
end
else
--- print('LibInspect:RemoveHook Unkown Type ', what);
return false;
end
else
--- print('LibInspect:RemoveHook No Addon Passed');
return false;
end
end
function lib:SetMaxAge(maxAge)
if maxAge < self.maxAge then
self.maxAge = maxAge;
end
return self.maxAge;
end
function lib:SetRescan(items)
if tonumber(items) and items >= 0 and items <= 15 then
self.rescan = items;
end
return self.rescan;
end
function lib:RequestData(what, target, force)
-- Error out on a few things
if not target then return false end
if InCombatLockdown() then return false end
if not CanInspect(target) then return false end
if not what then what = 'all'; end
-- We can skip some things if target is player
local skip = false;
if target == 'player' or UnitIsUnit('player', target) then
skip = true;
end
-- Manual requests reset the rescan lock
self.rescanGUID[target] = 0;
-- Make sure they are in cache
local guid = self:AddCharacter(target);
if guid then
-- First check for cached
if self.cache[guid].data == false or self.cache[guid].time == 0 or (time() - self.cache[guid].time) > self.maxAge or force then
self.cache[guid].target = target;
if what == 'all' then
self:SafeRequestItems(target, guid, skip);
self:SafeRequestHonor(target, guid, skip);
self:SafeRequestAchivements(target, guid, skip);
elseif what == 'items' then
self:SafeRequestItems(target, guid, skip);
elseif what == 'honor' then
self:SafeRequestHonor(target, guid, skip);
elseif what == 'talents' then
self:SafeRequestItems(target, guid, skip);
elseif what == 'achivements' then
self:SafeRequestAchivements(target, guid, skip);
else
--- print('LibInspect:RequestData Unkown Type ', what);
return false;
end
return true, true, true;
else
if what == 'all' then
self:RunHooks('items', guid);
self:RunHooks('honor', guid);
self:RunHooks('talents', guid);
self:RunHooks('achivements', guid);
elseif what == 'items' then
self:RunHooks('items', guid);
elseif what == 'honor' then
self:RunHooks('honor', guid);
elseif what == 'talents' then
self:RunHooks('talents', guid);
elseif what == 'achivements' then
self:RunHooks('achivements', guid);
else
--- print('LibInspect:RequestData Unkown Type ', what);
return false;
end
return true, true, false;
end
else
--- print('LibInspect:RequestData AddCharacter failed to turn a guid ', target, guid, ' another go at guid ', UnitGUID(target));
return true, false;
end
end
-- Shortcuts
function lib:RequestItems(target, force) return self:RequestData('items', target, force); end
function lib:RequestHonor(target, force) return self:RequestData('items', target, force); end
function lib:RequestTalents(target, force) return self:RequestData('items', target, force); end
function lib:RequestAchivements(target, force) return self:RequestData('achivements', target, force); end
-- Safe Functions for Requests
function lib:SafeRequestItems(target, guid, skip)
-- We can skip everything else
if skip then
self:InspectReady(guid)
return
end
local canInspect = false;
if not self.cache[guid].inspect then
canInspect = true;
elseif self.cache[guid].inspect and tonumber(self.cache[guid].inspect) and self:GetAge(self.cache[guid].inspect) > 5 then
canInspect = true;
end
if canInspect then
-- Fix an inspect frame bug, may be fixed in 4.3
-- if InspectFrame then InspectFrame.unit = target; end
--- print('LibInspect:SafeRequestItems running NotifyInspect for', UnitName(target), target);
self.cache[guid].inspect = time();
NotifyInspect(target);
end
end
function lib:SafeRequestHonor(target, guid, skip)
RequestInspectHonorData();
end
function lib:SafeRequestAchivements(target, guid, skip)
end
function lib:InspectReady(guid)
-- Few more error checks
if not guid then return false end
if InCombatLockdown() then return false end
--- print('LibInspect:InspectReady', guid, self.cache[guid]);
-- Make sure we have a target and its the same as the cache
if self.cache[guid] and self.cache[guid].target and UnitGUID(self.cache[guid].target) == guid then
local target = self.cache[guid].target;
-- Make sure we can still inspect them still
if CanInspect(target) then
self.cache[guid].time = time();
if not self.cache[guid].data then
self.cache[guid].data = {};
end
self.cache[guid].inspect = false;
self.cache[guid].data['items'] = {};
local items, count = self:GetItems(target, guid);
local talents = self:GetTalents(target, guid);
--- print('LibInspect:InspectReady Done', UnitName(target), guid, self.rescanGUID[target], count);
-- Do a 2nd pass if there aren't many items
if count <= self.rescan and self.rescanGUID[target] ~= guid then
--- print('LibInspect:InspectReady Rescaning', UnitName('target'), count, self.rescan, self.rescanGUID[target], guid);
self.rescanGUID[target] = guid;
self:SafeRequestItems(target, guid);
return false;
end
self.cache[guid].data.items = items;
self.cache[guid].data.talents = talents;
end
self:RunHooks('items', guid);
self:RunHooks('talents', guid);
end
end
function lib:GetItems(target, guid)
if CanInspect(target) then
local items = {};
local count = 0;
for i = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED do
local itemLink = GetInventoryItemLink(target, i);
items[i] = itemLink;
if itemLink then
--- print('LibInspect:GetItems', UnitName(target), i, itemLink);
count = count + 1;
end
end
--- print('LibInspect:GetItems Total', UnitName(target), count);
return items, count;
else
return false;
end
end
function lib:GetTalents(target, guid)
if CanInspect(target) then
local specID
if target == 'player' or UnitIsUnit('player', target) then
if GetSpecialization() then
specID = GetSpecializationInfo(GetSpecialization())
else
return false
end
else
specID = GetInspectSpecialization(target)
end
if (specID) then
local id, name, description, icon, background = GetSpecializationInfoByID(specID)
local role = GetSpecializationRoleByID(specID)
local talents = {
id = id,
name = name,
description = description,
icon = icon,
background = background,
role = role,
glyphs = {}, -- Removed in 7.03, left for compatability
talents = {},
};
-- Talents
local classDisplayName, class, classID = UnitClass(target);
if TalentFrame then
for tier=1, MAX_TALENT_TIERS do
local talentRow = TalentFrame["tier"..tier];
local rowAvailable = true;
for column=1, NUM_TALENT_COLUMNS do
local talentID, name, iconTexture, selected, available = GetTalentInfo(tier, column, TalentFrame.talentGroup, TalentFrame.inspect, talentUnit);
-- local name, iconTexture, tier, column, selected, available = GetTalentInfo(tier, true, nil, target, self.cache[guid].classID);
talents.talents[tier] = {
name = name,
iconTexture = iconTexture,
tier = tier,
column = column,
selected = selected,
available = available,
}
end
end
end
return talents;
else
return false;
end
else
return false;
end
end
function lib:AddCharacter(target)
local guid = UnitGUID(target);
if guid then
-- Set up information
if not self.cache[guid] then
local _, _, classID = UnitClass(target);
self.cache[guid] = {
data = false,
time = 0,
request = 0,
inspect = false,
classID = classID,
};
end
-- Update target cache
self.cache[guid].target = target;
-- Return guid to save on calls
return guid;
else
return false;
end
end
function lib:RunHooks(what, guid)
for addon,callback in pairs(self.hooks[what]) do
if callback then
callback(guid, self.cache[guid].data, self:GetAge(self.cache[guid].time));
end
end
end
function lib:GetAge(t)
if tonumber(t) then
return time() - tonumber(t);
else
return false;
end
end
function lib:count(tbl)
local i = 0;
for k,v in pairs(tbl) do
i = i + 1;
end
return i;
end
local function OnEvent(self, event, ...)
if event == 'INSPECT_READY' then
lib:InspectReady(...);
elseif event == 'INSPECT_HONOR_UPDATE' then
lib:InspectHonorUpdate(...);
elseif event == 'INSPECT_ACHIEVEMENT_READY' then
lib:InspectAchievementReady(...);
end
end
lib.frame:SetScript("OnEvent", OnEvent);
--------------------------------- -- LibItemLevel Author: M --------------------------------- local MAJOR, MINOR = "LibItemLevel-ElvUI", 1 local lib = LibStub:NewLibrary(MAJOR, MINOR) if not lib then return end local ItemLevelPattern = gsub(ITEM_LEVEL, "%%d", "(%%d+)") --Toolip local tooltip = CreateFrame("GameTooltip", "LibItemLevelTooltip1", UIParent, "GameTooltipTemplate") local unittip = CreateFrame("GameTooltip", "LibItemLevelTooltip2", UIParent, "GameTooltipTemplate") function lib:hasLocally(ItemID) if (not ItemID or ItemID == "" or ItemID == "0") then return true end return select(10, GetItemInfo(tonumber(ItemID))) end function lib:itemLocally(ItemLink) local id, gem1, gem2, gem3 = string.match(ItemLink, "item:(%d+):[^:]*:(%d-):(%d-):(%d-):") return (self:hasLocally(id) and self:hasLocally(gem1) and self:hasLocally(gem2) and self:hasLocally(gem3)) end function lib:GetStatsViaTooltip(tip, stats) if (type(stats) == "table") then local line, text, r, g, b, statValue, statName for i = 2, tip:NumLines() do line = _G[tip:GetName().."TextLeft" .. i] text = line:GetText() or "" r, g, b = line:GetTextColor() for statValue, statName in string.gmatch(text, "%+([0-9,]+)([^%+%|]+)") do statName = strtrim(statName) statName = statName:gsub("與$", "") --zhTW statName = statName:gsub(",", "") --zhCN statName = statName:gsub("%s*&$", "") --enUS statValue = statValue:gsub(",","") statValue = tonumber(statValue) or 0 if (not stats[statName]) then stats[statName] = { value = statValue, r = r, g = g, b = b } else stats[statName].value = stats[statName].value + statValue if (g > stats[statName].g) then stats[statName].r = r stats[statName].g = g stats[statName].b = b end end end end end return stats end function lib:GetItemInfo(ItemLink, stats) if (not ItemLink or ItemLink == "") then return 0, 0 end if (not string.match(ItemLink, "item:%d+:")) then return -1, 0 end if (not self:itemLocally(ItemLink)) then return 1, 0 end tooltip:SetOwner(UIParent, "ANCHOR_NONE") tooltip:SetHyperlink(ItemLink) local text, level for i = 2, 5 do text = _G[tooltip:GetName().."TextLeft" .. i]:GetText() or "" level = string.match(text, ItemLevelPattern) if (level) then break end end self:GetStatsViaTooltip(tooltip, stats) return 0, tonumber(level) or 0, GetItemInfo(ItemLink) end function lib:GetUnitItemInfo(unit, index, stats) if (not UnitExists(unit)) then return 1, 0 end unittip:SetOwner(UIParent, "ANCHOR_NONE") unittip:SetInventoryItem(unit, index) local ItemLink = GetInventoryItemLink(unit, index) or select(2, unittip:GetItem()) if (not ItemLink or ItemLink == "") then return 0, 0 end if (not self:itemLocally(ItemLink)) then return 1, 0 end local text, level for i = 2, 5 do text = _G[unittip:GetName().."TextLeft" .. i]:GetText() or "" level = string.match(text, ItemLevelPattern) if (level) then break end end self:GetStatsViaTooltip(unittip, stats) if (string.match(ItemLink, "item:(%d+):")) then return 0, tonumber(level) or 0, GetItemInfo(ItemLink) else local line = _G[unittip:GetName().."TextLeft1"] local r, g, b = line:GetTextColor() local name = WrapTextInColorCode(line:GetText() or "", ("ff%.2x%.2x%.2x"):format((r or 1)*255, (g or 1)*255, (b or 1)*255)) return 0, tonumber(level) or 0, name end end function lib:GetUnitItemLevel(unit, stats) local total, counts = 0, 0 local _, count, level for i = 1, 15 do if (i ~= 4) then count, level = self:GetUnitItemInfo(unit, i, stats) total = total + level counts = counts + count end end local mcount, mlevel, mquality, mslot, ocount, olevel, oquality, oslot mcount, mlevel, _, _, mquality, _, _, _, _, _, mslot = self:GetUnitItemInfo(unit, 16, stats) ocount, olevel, _, _, oquality, _, _, _, _, _, oslot = self:GetUnitItemInfo(unit, 17, stats) counts = counts + mcount + ocount if (mquality == 6 or oquality == 6) then total = total + max(mlevel, olevel) * 2 else total = total + mlevel + olevel end return counts, total/max(16-counts,1), total end
\ No newline at end of file
......@@ -26,6 +26,4 @@
<Include file="LibCompress\lib.xml"/>
<Include file="LibBase64-1.0\lib.xml"/>
<Script file="LibAnim\LibAnim.lua"/>
<Script file="LibItemLevel\LibItemLevel.lua"/>
<Script file="LibInspect\LibInspect.lua"/>
</Ui>
......@@ -2,7 +2,6 @@ local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, Private
local mod = E:GetModule('DataBars');
local LSM = E.Libs.LSM
--Cache global variables
--Lua functions
local floor = floor
local format = string.format
......
......@@ -2,7 +2,6 @@ local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, Private
local mod = E:NewModule("DataBars", 'AceEvent-3.0')
E.DataBars = mod
--Cache global variables
--WoW API / Variables
local CreateFrame = CreateFrame
local GetExpansionLevel = GetExpansionLevel
......
......@@ -2,7 +2,6 @@ local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, Private
local mod = E:GetModule('DataBars');
local LSM = E.Libs.LSM
--Cache global variables
--Lua functions
local format = format
local min = min
......
......@@ -2,7 +2,6 @@ local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, Private
local mod = E:GetModule('DataBars');
local LSM = E.Libs.LSM
--Cache global variables
--Lua functions
local format = format
--WoW API / Variables
......
......@@ -2,7 +2,6 @@ local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, Private
local mod = E:GetModule('DataBars');
local LSM = E.Libs.LSM
--Cache global variables
--Lua functions
local _G = _G
local format = format
......
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local AB = E:GetModule('ActionBars');
--Cache global variables
--Lua functions
local _G = _G
local select, tonumber, pairs = select, tonumber, pairs
......
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local AB = E:NewModule('ActionBars', 'AceHook-3.0', 'AceEvent-3.0');
--Cache global variables
--Lua functions
local _G = _G
local pairs, select, unpack = pairs, select, unpack
local ceil = math.ceil
local format, gsub, split, strfind = string.format, string.gsub, string.split, strfind
local format, gsub, strsplit, strfind = format, gsub, strsplit, strfind
--WoW API / Variables
local CanExitVehicle = CanExitVehicle
local ClearOverrideBindings = ClearOverrideBindings
local CreateFrame = CreateFrame
local C_PetBattles_IsInBattle = C_PetBattles.IsInBattle
local GameTooltip_Hide = GameTooltip_Hide
local GetBindingKey = GetBindingKey
local GetFlyoutID = GetFlyoutID
......@@ -40,17 +38,7 @@ local UnitOnTaxi = UnitOnTaxi