Add temporary Vendor Values runtime fix

This commit is contained in:
Dusk-92
2026-08-24 11:50:46 +02:00
parent d437102002
commit 5e96a33414
@@ -0,0 +1,252 @@
name: Temporary Vendor Values Runtime Fix
on:
push:
branches: [classicapi-enhanced]
paths:
- '.github/workflows/temp-vendor-runtime-fix.yml'
permissions:
contents: write
jobs:
patch:
if: github.actor != 'github-actions[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout ShaguTweaks
uses: actions/checkout@v4
with:
ref: classicapi-enhanced
- name: Replace Vendor Values tooltip runtime
shell: python
run: |
from pathlib import Path
target = Path('mods/vendor-values.lua')
text = target.read_text(encoding='utf-8')
marker = 'ShaguTweaks.SellValueDB = data\n'
head, sep, _ = text.partition(marker)
if not sep:
raise SystemExit('Vendor Values runtime marker not found')
runtime = r'''ShaguTweaks.SellValueDB = data
local function AddVendorPrices(frame, id, count)
local price = id and ShaguTweaks.SellValueDB[id]
count = math.max(tonumber(count) or 1, 1)
if price and price > 0 then
SetTooltipMoney(frame, price * count)
frame:Show()
end
end
local function AddVendorPriceFromLink(frame, link, count, ignoreMerchant)
if not link then return end
if not ignoreMerchant and MerchantFrame:IsShown() then return end
local itemID = GetItemIDFromLink(link)
if itemID then
AddVendorPrices(frame, itemID, count)
end
end
module.enable = function(self)
-- Add prices after the native tooltip setter has populated its contents.
-- The original module waited for a child-frame OnShow, which is not guaranteed
-- to fire when GameTooltip stays visible and its item changes.
local setterDepth = 0
local HookSetHyperlink = GameTooltip.SetHyperlink
function GameTooltip.SetHyperlink(self, link)
local result = HookSetHyperlink(self, link)
if setterDepth == 0 then
AddVendorPriceFromLink(self, link, 1, true)
end
return result
end
local HookSetItemRef = SetItemRef
SetItemRef = function(link, text, button)
local itemID = GetItemIDFromLink(link)
local result = HookSetItemRef(link, text, button)
if not IsAltKeyDown() and not IsShiftKeyDown() and not IsControlKeyDown() and itemID then
AddVendorPrices(ItemRefTooltip, itemID, 1)
end
return result
end
local HookSetBagItem = GameTooltip.SetBagItem
function GameTooltip.SetBagItem(self, container, slot)
local itemLink = GetContainerItemLink(container, slot)
local _, itemCount = GetContainerItemInfo(container, slot)
setterDepth = setterDepth + 1
local result = HookSetBagItem(self, container, slot)
setterDepth = setterDepth - 1
AddVendorPriceFromLink(self, itemLink, itemCount, false)
return result
end
local HookSetQuestLogItem = GameTooltip.SetQuestLogItem
function GameTooltip.SetQuestLogItem(self, itemType, index)
local itemLink = GetQuestLogItemLink(itemType, index)
setterDepth = setterDepth + 1
local result = HookSetQuestLogItem(self, itemType, index)
setterDepth = setterDepth - 1
AddVendorPriceFromLink(self, itemLink, 1, true)
return result
end
local HookSetQuestItem = GameTooltip.SetQuestItem
function GameTooltip.SetQuestItem(self, itemType, index)
local itemLink = GetQuestItemLink(itemType, index)
setterDepth = setterDepth + 1
local result = HookSetQuestItem(self, itemType, index)
setterDepth = setterDepth - 1
AddVendorPriceFromLink(self, itemLink, 1, true)
return result
end
local HookSetLootItem = GameTooltip.SetLootItem
function GameTooltip.SetLootItem(self, slot)
local itemLink = GetLootSlotLink(slot)
setterDepth = setterDepth + 1
local result = HookSetLootItem(self, slot)
setterDepth = setterDepth - 1
AddVendorPriceFromLink(self, itemLink, 1, true)
return result
end
local HookSetInboxItem = GameTooltip.SetInboxItem
function GameTooltip.SetInboxItem(self, mailID, attachmentIndex)
local itemName, _, itemCount = GetInboxItem(mailID, attachmentIndex)
local itemLink = itemName and GetItemLinkByName(itemName)
setterDepth = setterDepth + 1
local result = HookSetInboxItem(self, mailID, attachmentIndex)
setterDepth = setterDepth - 1
AddVendorPriceFromLink(self, itemLink, itemCount, true)
return result
end
local HookSetInventoryItem = GameTooltip.SetInventoryItem
function GameTooltip.SetInventoryItem(self, unit, slot)
local itemLink = GetInventoryItemLink(unit, slot)
setterDepth = setterDepth + 1
local result = HookSetInventoryItem(self, unit, slot)
setterDepth = setterDepth - 1
AddVendorPriceFromLink(self, itemLink, 1, true)
return result
end
local HookSetLootRollItem = GameTooltip.SetLootRollItem
function GameTooltip.SetLootRollItem(self, id)
local itemLink = GetLootRollItemLink(id)
setterDepth = setterDepth + 1
local result = HookSetLootRollItem(self, id)
setterDepth = setterDepth - 1
AddVendorPriceFromLink(self, itemLink, 1, true)
return result
end
local HookSetMerchantItem = GameTooltip.SetMerchantItem
function GameTooltip.SetMerchantItem(self, merchantIndex)
local itemLink = GetMerchantItemLink(merchantIndex)
setterDepth = setterDepth + 1
local result = HookSetMerchantItem(self, merchantIndex)
setterDepth = setterDepth - 1
AddVendorPriceFromLink(self, itemLink, 1, false)
return result
end
local HookSetCraftItem = GameTooltip.SetCraftItem
function GameTooltip.SetCraftItem(self, skill, slot)
local itemLink = GetCraftReagentItemLink(skill, slot)
setterDepth = setterDepth + 1
local result = HookSetCraftItem(self, skill, slot)
setterDepth = setterDepth - 1
AddVendorPriceFromLink(self, itemLink, 1, true)
return result
end
local HookSetCraftSpell = GameTooltip.SetCraftSpell
function GameTooltip.SetCraftSpell(self, slot)
local itemLink = GetCraftItemLink(slot)
setterDepth = setterDepth + 1
local result = HookSetCraftSpell(self, slot)
setterDepth = setterDepth - 1
AddVendorPriceFromLink(self, itemLink, 1, true)
return result
end
local HookSetTradeSkillItem = GameTooltip.SetTradeSkillItem
function GameTooltip.SetTradeSkillItem(self, skillIndex, reagentIndex)
local itemLink
if reagentIndex then
itemLink = GetTradeSkillReagentItemLink(skillIndex, reagentIndex)
else
itemLink = GetTradeSkillItemLink(skillIndex)
end
setterDepth = setterDepth + 1
local result = HookSetTradeSkillItem(self, skillIndex, reagentIndex)
setterDepth = setterDepth - 1
AddVendorPriceFromLink(self, itemLink, 1, true)
return result
end
local HookSetAuctionItem = GameTooltip.SetAuctionItem
function GameTooltip.SetAuctionItem(self, atype, index)
local _, _, itemCount = GetAuctionItemInfo(atype, index)
local itemLink = GetAuctionItemLink(atype, index)
setterDepth = setterDepth + 1
local result = HookSetAuctionItem(self, atype, index)
setterDepth = setterDepth - 1
AddVendorPriceFromLink(self, itemLink, itemCount, true)
return result
end
local HookSetAuctionSellItem = GameTooltip.SetAuctionSellItem
function GameTooltip.SetAuctionSellItem(self)
local itemName, _, itemCount = GetAuctionSellItemInfo()
local itemLink = itemName and GetItemLinkByName(itemName)
setterDepth = setterDepth + 1
local result = HookSetAuctionSellItem(self)
setterDepth = setterDepth - 1
AddVendorPriceFromLink(self, itemLink, itemCount, true)
return result
end
local HookSetTradePlayerItem = GameTooltip.SetTradePlayerItem
function GameTooltip.SetTradePlayerItem(self, index)
local itemLink = GetTradePlayerItemLink(index)
setterDepth = setterDepth + 1
local result = HookSetTradePlayerItem(self, index)
setterDepth = setterDepth - 1
AddVendorPriceFromLink(self, itemLink, 1, true)
return result
end
local HookSetTradeTargetItem = GameTooltip.SetTradeTargetItem
function GameTooltip.SetTradeTargetItem(self, index)
local itemLink = GetTradeTargetItemLink(index)
setterDepth = setterDepth + 1
local result = HookSetTradeTargetItem(self, index)
setterDepth = setterDepth - 1
AddVendorPriceFromLink(self, itemLink, 1, true)
return result
end
end
'''
target.write_text(head + runtime, encoding='utf-8', newline='\n')
print('Replaced Vendor Values tooltip runtime')
- name: Commit runtime fix
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add mods/vendor-values.lua
git diff --cached --stat
git commit -m "Fix Vendor Values tooltip updates for Turtle items"
git push origin HEAD:classicapi-enhanced