Init.lua 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. local myname, ns = ...
  2. local ItemSearch = ns.LibItemSearch
  3. ns.LibItemSearch = nil
  4. local NUMROWS, SCROLLSTEP = 14, 5
  5. local function Hide(frame)
  6. frame:Hide()
  7. frame.Show = frame.Hide
  8. end
  9. local function ToggleButtons()
  10. for i=1,MERCHANT_ITEMS_PER_PAGE do
  11. if (MerchantFrame.selectedTab == 1) then
  12. _G["MerchantItem"..i]:Hide()
  13. elseif (MerchantFrame.selectedTab == 2) then
  14. _G["MerchantItem"..i]:Show()
  15. end
  16. end
  17. end
  18. function ns.OnLoad()
  19. local GVS = ns.NewMainFrame()
  20. GVS:SetWidth(315)
  21. GVS:SetHeight(294)
  22. GVS:SetPoint("TOPLEFT", MerchantFrame, 8, -67)
  23. -- Reanchor the buyback button, it acts weird when switching tabs otherwise...
  24. MerchantBuyBackItem:ClearAllPoints()
  25. MerchantBuyBackItem:SetPoint("BOTTOMRIGHT", -7, 33)
  26. -- The little class select dropdown show trigget a refresh
  27. --[[hooksecurefunc("SetMerchantFilter", function()
  28. if GVS.Merchant ~= UnitGUID("npc") then
  29. GVS:GetScript("OnShow")(GVS)
  30. else
  31. GVS:GetScript("OnEvent")(GVS)
  32. end
  33. end)]]
  34. -- Force show when we're loaded on demand and the tab is already selected
  35. if MerchantFrame:IsVisible() and MerchantFrame.selectedTab == 1 then
  36. GVS:Show()
  37. end
  38. -- Reparent the first 10 MerchantItem frames, so they only appear for buyback
  39. for i=1,10 do _G["MerchantItem"..i]:Hide() end
  40. -- Hide frames we don't need now
  41. Hide(MerchantNextPageButton)
  42. Hide(MerchantPrevPageButton)
  43. Hide(MerchantPageText)
  44. -- Clean up our frame factories
  45. for i,v in pairs(ns) do if i:match("^New") then ns[i] = nil end end
  46. MerchantFrameTab1:HookScript("OnClick", ToggleButtons)
  47. MerchantFrameTab2:HookScript("OnClick", ToggleButtons)
  48. GVS:HookScript("OnShow", ToggleButtons)
  49. end