mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-30 11:10:00 +00:00
sellvalue: rewrite
This commit is contained in:
+14
@@ -41,6 +41,20 @@ function pfUI.api.round(input, places)
|
||||
end
|
||||
end
|
||||
|
||||
-- [ GetItemLinkByName ]
|
||||
-- Returns an itemLink for the given itemname
|
||||
-- 'name' [string] name of the item
|
||||
-- returns: [string] entire itemLink for the given item
|
||||
function pfUI.api.GetItemLinkByName(name)
|
||||
for itemID = 1, 25818 do
|
||||
local itemName, hyperLink, itemQuality = GetItemInfo(itemID)
|
||||
if (itemName and itemName == name) then
|
||||
local _, _, _, hex = GetItemQualityColor(tonumber(itemQuality))
|
||||
return hex.. "|H"..hyperLink.."|h["..itemName.."]|h|r"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- [ hooksecurefunc ]
|
||||
-- Hooks a global function and injects custom code
|
||||
-- 'name' [string] name of the function that shold be hooked
|
||||
|
||||
+110
-13
@@ -1,20 +1,19 @@
|
||||
pfUI:RegisterModule("sellvalue", function ()
|
||||
pfUI.sellvalue = CreateFrame( "Frame" , "pfUIsellvalue", GameTooltip )
|
||||
pfUI.sellvalue = CreateFrame( "Frame" , "pfGameTooltip", GameTooltip )
|
||||
|
||||
pfUI.sellvalue:SetScript("OnHide", function()
|
||||
GameTooltip.itemLink = nil
|
||||
GameTooltip.itemCount = nil
|
||||
end)
|
||||
|
||||
pfUI.sellvalue:SetScript("OnShow", function()
|
||||
if GetMouseFocus() and GetMouseFocus():GetParent() then
|
||||
local bag = GetMouseFocus():GetParent():GetID()
|
||||
local slot = GetMouseFocus():GetID()
|
||||
local _, count = GetContainerItemInfo(bag, slot)
|
||||
local itemLink = GetContainerItemLink(bag, slot);
|
||||
if not itemLink then return end
|
||||
if GameTooltip.itemLink then
|
||||
local _, _, itemID = string.find(GameTooltip.itemLink, "item:(%d+):%d+:%d+:%d+")
|
||||
local itemID = tonumber(itemID)
|
||||
local count = GameTooltip.itemCount or 1
|
||||
|
||||
local _, _, iid = string.find(itemLink, "item:(%d+):%d+:%d+:%d+")
|
||||
local _, _, itemLink = string.find(itemLink, "(item:%d+:%d+:%d+:%d+)");
|
||||
local itemName = GetItemInfo(itemLink)
|
||||
|
||||
if pfSellData[tonumber(iid)] and itemName == _G["GameTooltipTextLeft1"]:GetText() then
|
||||
local _, _, sell, buy = strfind(pfSellData[tonumber(iid)], "(.*),(.*)")
|
||||
if pfSellData[itemID] then
|
||||
local _, _, sell, buy = strfind(pfSellData[itemID], "(.*),(.*)")
|
||||
sell = tonumber(sell)
|
||||
buy = tonumber(buy)
|
||||
|
||||
@@ -41,4 +40,102 @@ pfUI:RegisterModule("sellvalue", function ()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local pfHookSetBagItem = GameTooltip.SetBagItem
|
||||
function GameTooltip.SetBagItem(self, container, slot)
|
||||
GameTooltip.itemLink = GetContainerItemLink(container, slot)
|
||||
_, GameTooltip.itemCount = GetContainerItemInfo(container, slot)
|
||||
return pfHookSetBagItem(self, container, slot)
|
||||
end
|
||||
|
||||
local pfHookSetQuestLogItem = GameTooltip.SetQuestLogItem
|
||||
function GameTooltip.SetQuestLogItem(self, itemType, index)
|
||||
GameTooltip.itemLink = GetQuestLogItemLink(itemType, index)
|
||||
return pfHookSetQuestLogItem(self, itemType, index)
|
||||
end
|
||||
|
||||
local pfHookSetQuestItem = GameTooltip.SetQuestItem
|
||||
function GameTooltip.SetQuestItem(self, itemType, index)
|
||||
GameTooltip.itemLink = GetQuestItemLink(itemType, index)
|
||||
return pfHookSetQuestItem(self, itemType, index)
|
||||
end
|
||||
|
||||
local pfHookSetLootItem = GameTooltip.SetLootItem
|
||||
function GameTooltip.SetLootItem(self, slot)
|
||||
GameTooltip.itemLink = GetLootSlotLink(slot)
|
||||
pfHookSetLootItem(self, slot)
|
||||
end
|
||||
|
||||
local pfHookSetInboxItem = GameTooltip.SetInboxItem
|
||||
function GameTooltip.SetInboxItem(self, mailID, attachmentIndex)
|
||||
local itemName, itemTexture, inboxItemCount, inboxItemQuality = GetInboxItem(mailID)
|
||||
GameTooltip.itemLink = GetItemLinkByName(itemName)
|
||||
return pfHookSetInboxItem(self, mailID, attachmentIndex)
|
||||
end
|
||||
|
||||
local pfHookSetInventoryItem = GameTooltip.SetInventoryItem
|
||||
function GameTooltip.SetInventoryItem(self, unit, slot)
|
||||
GameTooltip.itemLink = GetInventoryItemLink(unit, slot)
|
||||
return pfHookSetInventoryItem(self, unit, slot)
|
||||
end
|
||||
|
||||
local pfHookSetLootRollItem = GameTooltip.SetLootRollItem
|
||||
function GameTooltip.SetLootRollItem(self, id)
|
||||
GameTooltip.itemLink = GetLootRollItemLink(id)
|
||||
return pfHookSetLootRollItem(self, id)
|
||||
end
|
||||
|
||||
local pfHookSetLootRollItem = GameTooltip.SetLootRollItem
|
||||
function GameTooltip.SetLootRollItem(self, id)
|
||||
GameTooltip.itemLink = GetLootRollItemLink(id)
|
||||
return pfHookSetLootRollItem(self, id)
|
||||
end
|
||||
|
||||
local pfHookSetMerchantItem = GameTooltip.SetMerchantItem
|
||||
function GameTooltip.SetMerchantItem(self, merchantIndex)
|
||||
GameTooltip.itemLink = GetMerchantItemLink(merchantIndex)
|
||||
return pfHookSetMerchantItem(self, merchantIndex)
|
||||
end
|
||||
|
||||
local pfHookSetCraftItem = GameTooltip.SetCraftItem
|
||||
function GameTooltip.SetCraftItem(self, skill, slot)
|
||||
GameTooltip.itemLink = GetCraftReagentItemLink(skill, slot)
|
||||
return pfHookSetCraftItem(self, skill, slot)
|
||||
end
|
||||
|
||||
local pfHookSetCraftSpell = GameTooltip.SetCraftSpell
|
||||
function GameTooltip.SetCraftSpell(self, slot)
|
||||
GameTooltip.itemLink = GetCraftItemLink(slot)
|
||||
return pfHookSetCraftSpell(self, slot)
|
||||
end
|
||||
|
||||
local pfHookSetTradeSkillItem = GameTooltip.SetTradeSkillItem
|
||||
function GameTooltip.SetTradeSkillItem(self, skillIndex, reagentIndex)
|
||||
if reagentIndex then
|
||||
GameTooltip.itemLink = GetTradeSkillReagentItemLink(skillIndex, reagentIndex)
|
||||
else
|
||||
GameTooltip.itemLink = GetTradeSkillItemLink(skillIndex)
|
||||
end
|
||||
return pfHookSetTradeSkillItem(self, skillIndex, reagentIndex)
|
||||
end
|
||||
|
||||
local pfHookSetAuctionSellItem = GameTooltip.SetAuctionSellItem
|
||||
function GameTooltip.SetAuctionSellItem(self)
|
||||
local itemName, _, itemCount = GetAuctionSellItemInfo()
|
||||
GameTooltip.itemCount = itemCount
|
||||
GameTooltip.itemLink = GetItemLinkByName(itemName)
|
||||
return pfHookSetAuctionSellItem(self)
|
||||
end
|
||||
|
||||
local pfHookSetTradePlayerItem = GameTooltip.SetTradePlayerItem
|
||||
function GameTooltip.SetTradePlayerItem(self, index)
|
||||
GameTooltip.itemLink = GetTradePlayerItemLink(index)
|
||||
return pfHookSetTradePlayerItem(self, index)
|
||||
end
|
||||
|
||||
local pfHookSetTradeTargetItem = GameTooltip.SetTradeTargetItem
|
||||
function GameTooltip.SetTradeTargetItem(self, index)
|
||||
GameTooltip.itemLink = GetTradeTargetItemLink(index)
|
||||
return pfHookSetTradeTargetItem(self, index)
|
||||
end
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user