mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-04 12:40:02 +00:00
eqcompare: compare basic stats on items
This commit is contained in:
+10
@@ -310,6 +310,16 @@ function pfUI.api.hooksecurefunc(name, func, append)
|
||||
_G[name] = pfUI.hooks[tostring(func)]["function"]
|
||||
end
|
||||
|
||||
function pfUI.api.HookScript(f, script, func)
|
||||
local prev = f:GetScript(script)
|
||||
|
||||
f:SetScript(script, function(...)
|
||||
if prev then prev() end
|
||||
|
||||
func()
|
||||
end)
|
||||
end
|
||||
|
||||
-- [ QueueFunction ]
|
||||
-- Add functions to a FIFO queue for execution after a short delay.
|
||||
-- '...' [vararg] function, [arguments]
|
||||
|
||||
@@ -563,7 +563,7 @@ pfUI:RegisterModule("actionbar", function ()
|
||||
icon:SetTexCoord(.08, .92, .08, .92)
|
||||
|
||||
local texture = _G["PetActionButton"..i..'NormalTexture2']
|
||||
texture :SetAlpha(0)
|
||||
texture:SetAlpha(0)
|
||||
|
||||
local castable = _G["PetActionButton"..i..'AutoCastable']
|
||||
if C.bars.showcastable == "1" then
|
||||
|
||||
+82
-1
@@ -40,6 +40,16 @@ pfUI:RegisterModule("eqcompare", function ()
|
||||
[INVTYPE_THROWN] = "RangedSlot",
|
||||
}
|
||||
|
||||
HookScript(ShoppingTooltip1, "OnShow", function()
|
||||
local targetData = pfUI.eqcompare:ExtractAttributes(ShoppingTooltip1)
|
||||
pfUI.eqcompare:CompareAttributes(ShoppingTooltip1._data, targetData)
|
||||
end)
|
||||
|
||||
HookScript(ShoppingTooltip2, "OnShow", function()
|
||||
local targetData = pfUI.eqcompare:ExtractAttributes(ShoppingTooltip2)
|
||||
pfUI.eqcompare:CompareAttributes(ShoppingTooltip2._data, targetData)
|
||||
end)
|
||||
|
||||
pfUI.eqcompare = CreateFrame( "Frame" , "pfEQCompare", GameTooltip )
|
||||
pfUI.eqcompare.ShowCompare = function(tooltip)
|
||||
-- use GameTooltip as default
|
||||
@@ -49,6 +59,10 @@ pfUI:RegisterModule("eqcompare", function ()
|
||||
return
|
||||
end
|
||||
|
||||
local data = pfUI.eqcompare:ExtractAttributes(tooltip)
|
||||
ShoppingTooltip1._data = data
|
||||
ShoppingTooltip2._data = data
|
||||
|
||||
local border = tonumber(C.appearance.border.default)
|
||||
|
||||
for i=1,tooltip:NumLines() do
|
||||
@@ -93,10 +107,77 @@ pfUI:RegisterModule("eqcompare", function ()
|
||||
ShoppingTooltip2:SetInventoryItem("player", slotID_other)
|
||||
ShoppingTooltip2:Show();
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
pfUI.eqcompare:SetScript("OnShow", pfUI.eqcompare.ShowCompare)
|
||||
|
||||
local function startsWith(str, start)
|
||||
return string.sub(str, 1, string.len(start)) == start
|
||||
end
|
||||
|
||||
function pfUI.eqcompare:ExtractAttributes(tooltip)
|
||||
local name = tooltip:GetName()
|
||||
local data = {}
|
||||
for i=1,30 do
|
||||
local widget = _G[name.."TextLeft"..i]
|
||||
if widget and widget:GetObjectType() == "FontString" then
|
||||
local text = widget:GetText()
|
||||
if text and not string.find(text, "-", 1, true) then
|
||||
local start = 1
|
||||
if startsWith(text, "\+") or startsWith(text, "\(") then start = 2 end
|
||||
|
||||
local space = string.find(text, " ", 1, true)
|
||||
if space then
|
||||
local value = tonumber(string.sub(text, start, space-1))
|
||||
if value and text then
|
||||
-- we've found an attr
|
||||
local attr = string.sub(text, space, string.len(text))
|
||||
data[attr] = { value = tonumber(value), widget = widget }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return data
|
||||
end
|
||||
|
||||
function pfUI.eqcompare:CompareAttributes(data, targetData)
|
||||
if not data then return end
|
||||
for attr,v in pairs(data) do
|
||||
if targetData then
|
||||
local target = targetData[attr]
|
||||
if target then
|
||||
if v.value ~= target.value then
|
||||
if v.value > target.value then
|
||||
target.widget:SetTextColor(2.55, .08, .08)
|
||||
v.widget:SetTextColor(.2, 2.4, 0)
|
||||
else
|
||||
v.widget:SetTextColor(2.55, .08, .08)
|
||||
target.widget:SetTextColor(.2, 2.4, 0)
|
||||
end
|
||||
target.processed = true
|
||||
else
|
||||
target.processed = true
|
||||
end
|
||||
else
|
||||
-- this attribute doesnt exist in target
|
||||
v.widget:SetTextColor(.2, 2.4, 0)
|
||||
end
|
||||
else
|
||||
-- nothing to compare
|
||||
v.widget:SetTextColor(.2, 2.4, 0)
|
||||
end
|
||||
end
|
||||
|
||||
for _,target in pairs(targetData) do
|
||||
if target and not target.processed then
|
||||
-- we are an extra value
|
||||
target.widget:SetTextColor(.2, 2.4, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user