mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
update
This commit is contained in:
@@ -694,6 +694,25 @@ function GetItemCount(itemName)
|
||||
return count
|
||||
end
|
||||
|
||||
function GetContainerNumFreeSlots(bagID)
|
||||
local maxSlots = 0
|
||||
local usedSlots = 0
|
||||
|
||||
for bag = bagID, NUM_BAG_FRAMES do
|
||||
local bagSize = GetContainerNumSlots(bag)
|
||||
maxSlots = maxSlots + bagSize
|
||||
for i = 1, bagSize do
|
||||
itemLink = GetContainerItemLink(bag, i)
|
||||
if itemLink then
|
||||
usedSlots = usedSlots + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local freeSlots = maxSlots - usedSlots
|
||||
return freeSlots
|
||||
end
|
||||
|
||||
local scanTooltip
|
||||
function GetInventoryItemDurability(slot)
|
||||
if not GetInventoryItemTexture("player", slot) then return end
|
||||
@@ -712,4 +731,111 @@ function GetInventoryItemDurability(slot)
|
||||
return tonumber(current), tonumber(maximum)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local slots = {
|
||||
["HeadSlot"] = "INVTYPE_HEAD",
|
||||
["NeckSlot"] = "INVTYPE_NECK",
|
||||
["ShoulderSlot"] = "INVTYPE_SHOULDER",
|
||||
["BackSlot"] = "INVTYPE_CLOAK",
|
||||
["ChestSlot"] = "INVTYPE_ROBE",
|
||||
["WristSlot"] = "INVTYPE_WRIST",
|
||||
["HandsSlot"] = "INVTYPE_HAND",
|
||||
["WaistSlot"] = "INVTYPE_WAIST",
|
||||
["LegsSlot"] = "INVTYPE_LEGS",
|
||||
["FeetSlot"] = "INVTYPE_FEET",
|
||||
["Finger0Slot"] = "INVTYPE_FINGER",
|
||||
["Finger1Slot"] = "INVTYPE_FINGER",
|
||||
["Trinket0Slot"] = "INVTYPE_TRINKET",
|
||||
["Trinket1Slot"] = "INVTYPE_TRINKET",
|
||||
["MainHandSlot"] = "INVTYPE_WEAPONMAINHAND",
|
||||
["SecondaryHandSlot"] = "INVTYPE_HOLDABLE",
|
||||
["RangedSlot"] = "INVTYPE_RANGEDRIGHT",
|
||||
}
|
||||
|
||||
local bagsTable = {}
|
||||
function GetAverageItemLevel()
|
||||
local itemLink, itemLevel, itemEquipLoc
|
||||
local total, totalBag, item, bagItem, isBagItemLevel = 0, 0, 0, 0
|
||||
|
||||
for bag = 0, 4 do
|
||||
for slot = 1, GetContainerNumSlots(bag) do
|
||||
itemLink = GetContainerItemLink(bag, slot)
|
||||
if itemLink then
|
||||
_, _, _, itemLevel, _, _, _, _, itemEquipLoc = GetItemInfo(tonumber(string.match(itemLink, "item:(%d+)")))
|
||||
if itemEquipLoc and itemEquipLoc ~= "" then
|
||||
if not bagsTable[itemEquipLoc] then
|
||||
bagsTable[itemEquipLoc] = itemLevel
|
||||
else
|
||||
if itemLevel > bagsTable[itemEquipLoc] then
|
||||
bagsTable[itemEquipLoc] = itemLevel
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for slotName, itemLoc in pairs(slots) do
|
||||
itemLink = GetInventoryItemLink("player", GetInventorySlotInfo(slotName))
|
||||
if itemLink then
|
||||
_, _, _, itemLevel, _, _, _, _, itemEquipLoc = GetItemInfo(tonumber(string.match(itemLink, "item:(%d+)")))
|
||||
if itemLevel and itemLevel > 0 then
|
||||
item = item + 1
|
||||
bagItem = bagItem + 1
|
||||
|
||||
isBagItemLevel = bagsTable[itemEquipLoc]
|
||||
if isBagItemLevel and isBagItemLevel > itemLevel then
|
||||
totalBag = totalBag + isBagItemLevel
|
||||
else
|
||||
totalBag = totalBag + itemLevel
|
||||
end
|
||||
|
||||
total = total + itemLevel
|
||||
end
|
||||
else
|
||||
isBagItemLevel = bagsTable[itemLoc]
|
||||
if isBagItemLevel then
|
||||
bagItem = bagItem + 1
|
||||
totalBag = totalBag + isBagItemLevel
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
wipe(bagsTable)
|
||||
|
||||
if total < 1 then
|
||||
return 0, 0
|
||||
end
|
||||
|
||||
return (totalBag / bagItem), (total / item)
|
||||
end
|
||||
|
||||
function GetItemLevelColor(unit)
|
||||
if not unit then unit = "player" end
|
||||
|
||||
local i = 0
|
||||
local sumR, sumG, sumB = 0, 0, 0
|
||||
for slotName, _ in pairs(slots) do
|
||||
local slotID = GetInventorySlotInfo(slotName)
|
||||
if GetInventoryItemTexture(unit, slotID) then
|
||||
local itemLink = GetInventoryItemLink(unit, slotID)
|
||||
if itemLink then
|
||||
local _, _, quality = GetItemInfo(tonumber(string.match(itemLink, "item:(%d+)")))
|
||||
if quality then
|
||||
i = i + 1
|
||||
local r, g, b = GetItemQualityColor(quality)
|
||||
sumR = sumR + r
|
||||
sumG = sumG + g
|
||||
sumB = sumB + b
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if i > 0 then
|
||||
return (sumR / i), (sumG / i), (sumB / i)
|
||||
else
|
||||
return 1, 1, 1
|
||||
end
|
||||
end
|
||||
@@ -4,9 +4,11 @@ local LDB = LibStub:GetLibrary("LibDataBroker-1.1");
|
||||
local LSM = LibStub("LibSharedMedia-3.0");
|
||||
local TT = E:GetModule("Tooltip");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
local pairs, type, error = pairs, type, error
|
||||
local len = string.len
|
||||
|
||||
--WoW API / Variables
|
||||
local CreateFrame = CreateFrame
|
||||
local IsInInstance = IsInInstance
|
||||
|
||||
|
||||
@@ -78,4 +78,4 @@ local function OnEnter(self)
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
DT:RegisterDatatext("Gold", {"PLAYER_ENTERING_WORLD", "PLAYER_MONEY", "SEND_MAIL_MONEY_CHANGED", "SEND_MAIL_COD_CHANGED", "PLAYER_TRADE_MONEY", "TRADE_MONEY_CHANGED"}, OnEvent, nil, OnClick, OnEnter, nil, L.gold)
|
||||
DT:RegisterDatatext("Gold", {"PLAYER_ENTERING_WORLD", "PLAYER_MONEY", "SEND_MAIL_MONEY_CHANGED", "SEND_MAIL_COD_CHANGED", "PLAYER_TRADE_MONEY", "TRADE_MONEY_CHANGED"}, OnEvent, nil, OnClick, OnEnter, nil, GOLD)
|
||||
Reference in New Issue
Block a user