From 077b944bdd92d2a6ca2b9a3ff721db0da7b82b7d Mon Sep 17 00:00:00 2001 From: Jazminite <65823478+jazminite@users.noreply.github.com> Date: Tue, 16 Aug 2022 16:21:31 -0400 Subject: [PATCH] Update Section.lua Changes proposed by Ragnoroct --- widgets/Section.lua | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/widgets/Section.lua b/widgets/Section.lua index 7b020d3a..5207b5c6 100644 --- a/widgets/Section.lua +++ b/widgets/Section.lua @@ -108,8 +108,15 @@ function sectionProto:OnCreate() end function sectionProto:OnShow() + local isFreeSpaceSection = self.key == "Free space#Free space" + local keySection = self.container:GetSection("Key", "Key") + for button in pairs(self.buttons) do - button:Show() + local buttonFamilyIsKeyChain = button.bagFamily == 256 or (button:IsStack() and button:GetBagFamily() == 256) + local shouldShow = not (keySection:IsCollapsed() and isFreeSpaceSection and buttonFamilyIsKeyChain) + if shouldShow then + button:Show() + end end end @@ -117,6 +124,15 @@ function sectionProto:OnHide() for button in pairs(self.buttons) do button:Hide() end + -- Also hide free keys section in the "Free space" + if self.key == "Key#Key" then + local section = self.container:GetSection("Free space", "Free space") + for button in pairs(section.buttons) do + if button.bagFamily == 256 or (button:IsStack() and button:GetBagFamily() == 256) then + button:Hide() + end + end + end end function sectionProto:ToString() @@ -358,9 +374,16 @@ function sectionProto:FullLayout() return self:Hide() end + local isFreeSpaceSection = self.key == "Free space#Free space" + local keySection = self.container:GetSection("Key", "Key") + for button in pairs(self.buttons) do - button:Show() - tinsert(buttonOrder, button) + local buttonFamilyIsKeyChain = button.bagFamily == 256 or (button:IsStack() and button:GetBagFamily() == 256) + local shouldShow = not (keySection:IsCollapsed() and isFreeSpaceSection and buttonFamilyIsKeyChain) + if shouldShow then + button:Show() + tinsert(buttonOrder, button) + end end tsort(buttonOrder, CompareButtons)