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()
|
||||
GVS:SetWidth(315)
|
||||
GVS:SetHeight(294)
|
||||
GVS:SetPoint("TOPLEFT", 8, -67)
|
||||
GVS:SetPoint("TOPLEFT", MerchantFrame, 8, -67)
|
||||
GVS:Hide()
|
||||
|
||||
|
||||
|
@ -33,20 +33,12 @@ function ns.OnLoad()
|
|||
MerchantBuyBackItem:SetPoint("BOTTOMRIGHT", -7, 33)
|
||||
|
||||
|
||||
local function Show()
|
||||
for i=1,12 do _G["MerchantItem"..i]:Hide() end
|
||||
if GVS:IsShown() then GVS:GetScript("OnShow")(GVS, true) else GVS:Show() end
|
||||
hooksecurefunc("SetMerchantFilter", function() GVS:GetScript("OnShow")(GVS) end)
|
||||
|
||||
|
||||
if MerchantFrame:IsVisible() and MerchantFrame.selectedTab == 1 then
|
||||
GVS:Show()
|
||||
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
|
||||
|
|
|
@ -10,7 +10,7 @@ local NUMROWS = 14
|
|||
|
||||
|
||||
function ns.NewMainFrame()
|
||||
local GVS = CreateFrame("frame", nil, MerchantFrame)
|
||||
local GVS = CreateFrame("frame", nil, MerchantBuyBackItem)
|
||||
|
||||
local search = ns.MakeSearchField(GVS)
|
||||
|
||||
|
@ -62,17 +62,22 @@ function ns.NewMainFrame()
|
|||
end
|
||||
end)
|
||||
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)
|
||||
scrollbar:SetMinMaxValues(0, max)
|
||||
scrollbar:SetValue(noreset and math.min(scrollbar:GetValue(), max) or 0)
|
||||
scrollbar:SetValue(0)
|
||||
Refresh()
|
||||
|
||||
GVS:RegisterEvent("BAG_UPDATE")
|
||||
GVS:RegisterEvent("MERCHANT_UPDATE")
|
||||
GVS:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
|
||||
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
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue