Simplify show/hide a bit
This commit is contained in:
parent
b6fede093b
commit
36a115fcb0
20
Init.lua
20
Init.lua
|
@ -24,7 +24,7 @@ function ns.OnLoad()
|
||||||
local GVS = ns.NewMainFrame()
|
local GVS = ns.NewMainFrame()
|
||||||
GVS:SetWidth(315)
|
GVS:SetWidth(315)
|
||||||
GVS:SetHeight(294)
|
GVS:SetHeight(294)
|
||||||
GVS:SetPoint("TOPLEFT", 8, -67)
|
GVS:SetPoint("TOPLEFT", MerchantFrame, 8, -67)
|
||||||
GVS:Hide()
|
GVS:Hide()
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,20 +33,12 @@ function ns.OnLoad()
|
||||||
MerchantBuyBackItem:SetPoint("BOTTOMRIGHT", -7, 33)
|
MerchantBuyBackItem:SetPoint("BOTTOMRIGHT", -7, 33)
|
||||||
|
|
||||||
|
|
||||||
local function Show()
|
hooksecurefunc("SetMerchantFilter", function() GVS:GetScript("OnShow")(GVS) end)
|
||||||
for i=1,12 do _G["MerchantItem"..i]:Hide() end
|
|
||||||
if GVS:IsShown() then GVS:GetScript("OnShow")(GVS, true) else GVS:Show() end
|
|
||||||
|
if MerchantFrame:IsVisible() and MerchantFrame.selectedTab == 1 then
|
||||||
|
GVS:Show()
|
||||||
end
|
end
|
||||||
hooksecurefunc("MerchantFrame_UpdateMerchantInfo", Show)
|
|
||||||
|
|
||||||
|
|
||||||
hooksecurefunc("MerchantFrame_UpdateBuybackInfo", function()
|
|
||||||
GVS:Hide()
|
|
||||||
for i=1,12 do _G["MerchantItem"..i]:Show() end
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
if MerchantFrame:IsVisible() and MerchantFrame.selectedTab == 1 then Show() end
|
|
||||||
|
|
||||||
|
|
||||||
-- Clean up our frame factories
|
-- Clean up our frame factories
|
||||||
|
|
|
@ -10,7 +10,7 @@ local NUMROWS = 14
|
||||||
|
|
||||||
|
|
||||||
function ns.NewMainFrame()
|
function ns.NewMainFrame()
|
||||||
local GVS = CreateFrame("frame", nil, MerchantFrame)
|
local GVS = CreateFrame("frame", nil, MerchantBuyBackItem)
|
||||||
|
|
||||||
local search = ns.MakeSearchField(GVS)
|
local search = ns.MakeSearchField(GVS)
|
||||||
|
|
||||||
|
@ -62,17 +62,22 @@ function ns.NewMainFrame()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
GVS:SetScript("OnEvent", Refresh)
|
GVS:SetScript("OnEvent", Refresh)
|
||||||
GVS:SetScript("OnShow", function(self, noreset)
|
GVS:SetScript("OnShow", function(self)
|
||||||
|
for i=1,12 do _G["MerchantItem"..i]:Hide() end
|
||||||
|
|
||||||
local max = math.max(0, GetMerchantNumItems() - NUMROWS)
|
local max = math.max(0, GetMerchantNumItems() - NUMROWS)
|
||||||
scrollbar:SetMinMaxValues(0, max)
|
scrollbar:SetMinMaxValues(0, max)
|
||||||
scrollbar:SetValue(noreset and math.min(scrollbar:GetValue(), max) or 0)
|
scrollbar:SetValue(0)
|
||||||
Refresh()
|
Refresh()
|
||||||
|
|
||||||
GVS:RegisterEvent("BAG_UPDATE")
|
GVS:RegisterEvent("BAG_UPDATE")
|
||||||
GVS:RegisterEvent("MERCHANT_UPDATE")
|
GVS:RegisterEvent("MERCHANT_UPDATE")
|
||||||
GVS:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
|
GVS:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
|
||||||
end)
|
end)
|
||||||
GVS:SetScript("OnHide", GVS.UnregisterAllEvents)
|
GVS:SetScript("OnHide", function(self)
|
||||||
|
for i=1,12 do _G["MerchantItem"..i]:Show() end
|
||||||
|
self:UnregisterAllEvents()
|
||||||
|
end)
|
||||||
|
|
||||||
return GVS
|
return GVS
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue