Fix drag&drop, click and rightclick

This commit is contained in:
Robin 2021-02-05 20:25:52 +01:00
parent 75ed05e1d9
commit 125892f296
1 changed files with 44 additions and 31 deletions

View File

@ -1,10 +1,39 @@
local addonName, addon = ...
local events = events or CreateFrame("FRAME")
local prices, pricesIlvl
local function getItem()
return AuctionHouseFrame.CommoditiesSellFrame.ItemDisplay.ItemButton:GetItemLocation() or AuctionHouseFrame.ItemSellFrame.ItemDisplay.ItemButton:GetItemLocation()
end
local function hookItem(self, ...)
-- print('hook')
local il = getItem()
if(il) then
if(il:IsValid() and il:IsBagAndSlot()) then
local bid = C_Item.GetItemID(il)
if(bid) then
-- print("hook",self:GetName(), ...)
-- print(AuctionHouseFrame.CommoditiesSellFrame.ItemDisplay.ItemButton:GetItemLocation())
-- print(AuctionHouseFrame.ItemSellFrame.ItemDisplay.ItemButton:GetItemLocation())
if(C_AuctionHouse.GetItemCommodityStatus(il) and prices[bid]) then
-- print("CPrice", prices[bid])
else
local lvl = C_Item.GetCurrentItemLevel(il)
-- print(lvl)
-- print("Price",lvl,pricesIlvl[bid][lvl])
if(lvl and pricesIlvl[bid] and pricesIlvl[bid][lvl]) then
AuctionHouseFrame.ItemSellFrame.PriceInput:SetAmount(pricesIlvl[bid][lvl])
end
end
end
end
end
end
function events:ITEM_SEARCH_RESULTS_UPDATED(event, item)
local itemID = item['itemID']
-- print(itemID)
pricesIlvl[itemID] = pricesIlvl[itemID] or {}
-- print("id",itemID)
if(itemID) then
pricesIlvl[itemID] = {}
end
-- pricesIlvl[item['itemID']][item['itemLevel']] = 0
for i = 1, C_AuctionHouse.GetNumItemSearchResults(item) do
local result = C_AuctionHouse.GetItemSearchResultInfo(item, i)
@ -15,13 +44,16 @@ function events:ITEM_SEARCH_RESULTS_UPDATED(event, item)
if(itemlevel and not pricesIlvl[itemID][itemlevel]) then
pricesIlvl[itemID][itemlevel] = 0
end
-- print(itemlevel)
-- print(itemlevel, pricesIlvl[itemID][itemlevel], result.buyoutAmount,result.buyoutAmount<pricesIlvl[itemID][itemlevel])
if(pricesIlvl[itemID][itemlevel] == 0 or result.buyoutAmount<pricesIlvl[itemID][itemlevel]) then
pricesIlvl[itemID][itemlevel] = result.buyoutAmount
-- print("New price",itemlevel, result.buyoutAmount)
-- print("New price",itemlevel, result.buyoutAmount)
end
else
-- print("nr", result, result.buyoutAmount)
end
end
hookItem()
end
function events:COMMODITY_SEARCH_RESULTS_UPDATED(event, itemID)
prices[itemID] = 0
@ -34,35 +66,16 @@ function events:COMMODITY_SEARCH_RESULTS_UPDATED(event, itemID)
end
end
end
local function hookItem(self, ...)
local cItemLoc = AuctionHouseFrame.CommoditiesSellFrame.ItemDisplay.ItemButton:GetItemLocation()
local ItemLoc = AuctionHouseFrame.ItemSellFrame.ItemDisplay.ItemButton:GetItemLocation()
if(cItemLoc or ItemLoc) then
local il = cItemLoc or ItemLoc
if(il:IsValid() and il:IsBagAndSlot()) then
local bid = C_Item.GetItemID(il)
if(bid) then
-- print("hook",self:GetName(), ...)
-- print(AuctionHouseFrame.CommoditiesSellFrame.ItemDisplay.ItemButton:GetItemLocation())
-- print(AuctionHouseFrame.ItemSellFrame.ItemDisplay.ItemButton:GetItemLocation())
if(C_AuctionHouse.GetItemCommodityStatus(il) and prices[bid]) then
-- print("Price", prices[bid])
else
local lvl = C_Item.GetCurrentItemLevel(il)
-- print(lvl)
-- print("Price",pricesIlvl[bid][lvl])
if(lvl and pricesIlvl[bid] and pricesIlvl[bid][lvl]) then
AuctionHouseFrame.ItemSellFrame.PriceInput:SetAmount(pricesIlvl[bid][lvl])
end
end
end
end
end
end
function events:AUCTION_HOUSE_SHOW(event)
self:UnregisterEvent(event)
AuctionHouseFrame.CommoditiesSellFrame.Overlay:HookScript("OnReceiveDrag", hookItem)
AuctionHouseFrame.ItemSellFrame.ItemDisplay.ItemButton:HookScript("OnReceiveDrag", hookItem)
for k,v in pairs(AuctionHouseFrame.ItemSellFrame.ItemDisplay.ItemButton) do
-- print("-- ",k,v)
end
-- hooksecurefunc(AuctionHouseFrame.ItemSellFrame.ItemDisplay.ItemButton, "SwitchItemWithCursor", function(...) print("sil",...) end)
-- AuctionHouseFrame.CommoditiesSellFrame.Overlay:HookScript("OnReceiveDrag", hookItem)
-- AuctionHouseFrame.ItemSellFrame.ItemDisplay.ItemButton:HookScript("OnReceiveDrag", hookItem)
-- AuctionHouseFrame.ItemSellFrame.ItemDisplay.ItemButton:HookScript("OnClick", hookItem)
AuctionHouseFrameAuctionsFrame.ItemDisplay.ItemButton:HookScript("OnClick", function(self, button, ...)
if(button == "LeftButton") then
local itemid = self:GetParent().item