Toggle visibility with SetShown instead of Show/Hide branches

Each if/else that only showed one object in one branch and hid it in the other is now ClassicAPI's SetShown, which shows on any truthy value. 21 sites across 10 modules.
This commit is contained in:
Brues
2026-10-30 19:49:43 -05:00
parent f7680ded0b
commit 4616c2bc5f
10 changed files with 21 additions and 77 deletions
+7 -23
View File
@@ -414,11 +414,7 @@ pfUI:RegisterModule("actionbar", function ()
end end
-- equipped item -- equipped item
if IsEquippedAction(sid) and C.bars.showequipped == "1" then self.equipped:SetShown(IsEquippedAction(sid) and C.bars.showequipped == "1")
self.equipped:Show()
else
self.equipped:Hide()
end
end end
local start, duration, enable, castable, autocast, token local start, duration, enable, castable, autocast, token
@@ -506,11 +502,7 @@ pfUI:RegisterModule("actionbar", function ()
self.autocast:Hide() self.autocast:Hide()
end end
if castable and C.bars.showcastable == "1" then self.autocastable:SetShown(castable and C.bars.showcastable == "1")
self.autocastable:Show()
else
self.autocastable:Hide()
end
end end
-- keybinds -- keybinds
@@ -1116,7 +1108,7 @@ pfUI:RegisterModule("actionbar", function ()
end end
-- macro options -- macro options
if showmacro == "1" then f.macro:Show() else f.macro:Hide() end f.macro:SetShown(showmacro == "1")
SetAllPointsOffset(f.macro, f, font_offset, -font_offset) SetAllPointsOffset(f.macro, f, font_offset, -font_offset)
f.macro:SetFont(font, macro_size, "OUTLINE") f.macro:SetFont(font, macro_size, "OUTLINE")
f.macro:SetTextColor(unpack(macro_color)) f.macro:SetTextColor(unpack(macro_color))
@@ -1124,7 +1116,7 @@ pfUI:RegisterModule("actionbar", function ()
f.macro:SetJustifyV("BOTTOM") f.macro:SetJustifyV("BOTTOM")
-- keybind options -- keybind options
if showkybind == "1" then f.keybind:Show() else f.keybind:Hide() end f.keybind:SetShown(showkybind == "1")
SetAllPointsOffset(f.keybind, f, font_offset, -font_offset) SetAllPointsOffset(f.keybind, f, font_offset, -font_offset)
f.keybind:SetFont(font, bind_size, "OUTLINE") f.keybind:SetFont(font, bind_size, "OUTLINE")
f.keybind:SetTextColor(unpack(bind_color)) f.keybind:SetTextColor(unpack(bind_color))
@@ -1133,7 +1125,7 @@ pfUI:RegisterModule("actionbar", function ()
f.keybind:SetNonSpaceWrap(false) f.keybind:SetNonSpaceWrap(false)
-- item count options -- item count options
if showcount == "1" then f.count:Show() else f.count:Hide() end f.count:SetShown(showcount == "1")
SetAllPointsOffset(f.count, f, font_offset, -font_offset) SetAllPointsOffset(f.count, f, font_offset, -font_offset)
f.count:SetFont(font, count_size, "OUTLINE") f.count:SetFont(font, count_size, "OUTLINE")
f.count:SetTextColor(unpack(count_color)) f.count:SetTextColor(unpack(count_color))
@@ -1232,11 +1224,7 @@ pfUI:RegisterModule("actionbar", function ()
-- handle pet bar -- handle pet bar
if i == 12 then if i == 12 then
-- only show when pet actions exists -- only show when pet actions exists
if PetHasActionBar() or pfUI.unlock and pfUI.unlock:IsShown() then bars[i]:SetShown(PetHasActionBar() or pfUI.unlock and pfUI.unlock:IsShown())
bars[i]:Show()
else
bars[i]:Hide()
end
-- show/hide petbar on petbar updates -- show/hide petbar on petbar updates
if init then if init then
@@ -1256,11 +1244,7 @@ pfUI:RegisterModule("actionbar", function ()
-- handle shapeshift bar -- handle shapeshift bar
elseif i == 11 then elseif i == 11 then
-- only show when shapeshifts exist -- only show when shapeshifts exist
if GetNumShapeshiftForms() > 0 then bars[i]:SetShown(GetNumShapeshiftForms() > 0)
bars[i]:Show()
else
bars[i]:Hide()
end
-- update shapeshift bar when amount of spells changes -- update shapeshift bar when amount of spells changes
if init then if init then
+1 -5
View File
@@ -402,11 +402,7 @@ pfUI:RegisterModule("addonbuttons", function ()
-- rescan before deciding whether the panel should be shown by default -- rescan before deciding whether the panel should be shown by default
pfUI.addonbuttons:ProcessButtons() pfUI.addonbuttons:ProcessButtons()
if C.abuttons.showdefault == "1" and GetNumButtons() > 0 then pfUI.addonbuttons:SetShown(C.abuttons.showdefault == "1" and GetNumButtons() > 0)
pfUI.addonbuttons:Show()
else
pfUI.addonbuttons:Hide()
end
-- apply workarounds -- apply workarounds
for k, v in pairs(pfUI.addonbuttons.overrides) do for k, v in pairs(pfUI.addonbuttons.overrides) do
+1 -5
View File
@@ -86,11 +86,7 @@ pfUI:RegisterModule("autovendor", function ()
if not pfMerchantFrame_Update then if not pfMerchantFrame_Update then
local pfMerchantFrame_Update = MerchantFrame_Update local pfMerchantFrame_Update = MerchantFrame_Update
function _G.MerchantFrame_Update() function _G.MerchantFrame_Update()
if MerchantFrame.selectedTab == 1 and C["global"]["autosell"] ~= "1" then autovendor.button:SetShown(MerchantFrame.selectedTab == 1 and C["global"]["autosell"] ~= "1")
autovendor.button:Show()
else
autovendor.button:Hide()
end
pfMerchantFrame_Update() pfMerchantFrame_Update()
end end
end end
+3 -15
View File
@@ -40,11 +40,7 @@ pfUI:RegisterModule("bags", function ()
-- overwrite some bag functions -- overwrite some bag functions
function _G.OpenAllBags() function _G.OpenAllBags()
if pfUI.bag.right:IsShown() then pfUI.bag.right:SetShown(not pfUI.bag.right:IsShown())
pfUI.bag.right:Hide()
else
pfUI.bag.right:Show()
end
end end
function _G.CloseAllBags() function _G.CloseAllBags()
@@ -52,11 +48,7 @@ pfUI:RegisterModule("bags", function ()
end end
function _G.ToggleBackpack() function _G.ToggleBackpack()
if pfUI.bag.right:IsShown() then pfUI.bag.right:SetShown(not pfUI.bag.right:IsShown())
pfUI.bag.right:Hide()
else
pfUI.bag.right:Show()
end
end end
function _G.OpenBackpack() function _G.OpenBackpack()
@@ -1140,11 +1132,7 @@ pfUI:RegisterModule("bags", function ()
end) end)
frame.bags:SetScript("OnClick", function() frame.bags:SetScript("OnClick", function()
if pfUI.bag.left.bagslots:IsShown() then pfUI.bag.left.bagslots:SetShown(not pfUI.bag.left.bagslots:IsShown())
pfUI.bag.left.bagslots:Hide()
else
pfUI.bag.left.bagslots:Show()
end
end) end)
end end
+3 -3
View File
@@ -778,7 +778,7 @@ pfUI:RegisterModule("equipmentmanager", function()
function UpdatePopouts() function UpdatePopouts()
local show = PopoutsActive() local show = PopoutsActive()
for _, b in ipairs(popoutButtons) do for _, b in ipairs(popoutButtons) do
if show then b:Show() else b:Hide() end b:SetShown(show)
end end
if not show then flyout:Hide() end if not show then flyout:Hide() end
end end
@@ -831,7 +831,7 @@ pfUI:RegisterModule("equipmentmanager", function()
-- uncommitted user changes show immediately. -- uncommitted user changes show immediately.
local setIgnored = selectedSetID and GetEffectiveIgnored(selectedSetID) or {} local setIgnored = selectedSetID and GetEffectiveIgnored(selectedSetID) or {}
for slotID, overlay in pairs(slotOverlays) do for slotID, overlay in pairs(slotOverlays) do
if frame:IsShown() and selectedSetID and setIgnored[slotID] then overlay:Show() else overlay:Hide() end overlay:SetShown(frame:IsShown() and selectedSetID and setIgnored[slotID])
end end
local hasSelection = selectedSetID and true or false local hasSelection = selectedSetID and true or false
@@ -1170,7 +1170,7 @@ pfUI:RegisterModule("equipmentmanager", function()
unusedGrid.ScrollBox:SetDataProvider(CreateDataProvider(list), ScrollBoxConstants.RetainScrollPosition) unusedGrid.ScrollBox:SetDataProvider(CreateDataProvider(list), ScrollBoxConstants.RetainScrollPosition)
if total == 0 then unusedPanel.empty:Show() else unusedPanel.empty:Hide() end unusedPanel.empty:SetShown(total == 0)
bagHighlight.active = true bagHighlight.active = true
bagHighlight.locs = {} bagHighlight.locs = {}
+1 -5
View File
@@ -1,10 +1,6 @@
pfUI:RegisterModule("farmmode", function () pfUI:RegisterModule("farmmode", function ()
local function ToggleFarmMode() local function ToggleFarmMode()
if pfUI.farmmap:IsShown() then pfUI.farmmap:SetShown(not pfUI.farmmap:IsShown())
pfUI.farmmap:Hide()
else
pfUI.farmmap:Show()
end
end end
local function MoveNodes(layer) local function MoveNodes(layer)
+1 -5
View File
@@ -37,11 +37,7 @@ pfUI:RegisterModule("gryphons", function ()
frame.texture:SetTexCoord(1, 0, 0, 1) frame.texture:SetTexCoord(1, 0, 0, 1)
end end
if texture then frame:SetShown(texture)
frame:Show()
else
frame:Hide()
end
end end
end end
+1 -1
View File
@@ -266,7 +266,7 @@ pfUI:RegisterModule("loothistory", function ()
pf.rollicon:SetTexture(ROLL_TEX[rollType] or ROLL_TEX[ROLL_PASS]) pf.rollicon:SetTexture(ROLL_TEX[rollType] or ROLL_TEX[ROLL_PASS])
if roll and roll > 0 then pf.rolltext:SetText(roll) else pf.rolltext:SetText("") end if roll and roll > 0 then pf.rolltext:SetText(roll) else pf.rolltext:SetText("") end
if isWinner then pf.winmark:Show() else pf.winmark:Hide() end pf.winmark:SetShown(isWinner)
end end
local view = CreateScrollBoxListLinearView(2, 2, 4, 4, 2) local view = CreateScrollBoxListLinearView(2, 2, 4, 4, 2)
+1 -5
View File
@@ -74,11 +74,7 @@ pfUI:RegisterModule("thirdparty", function()
-- show/hide right chatframe -- show/hide right chatframe
if pfUI.chat and C.chat.right.enable == "1" then if pfUI.chat and C.chat.right.enable == "1" then
-- make sure the panel header stays hidden -- make sure the panel header stays hidden
if self.state then pfUI.chat.right.panelTop:SetShown(self.state)
pfUI.chat.right.panelTop:Show()
else
pfUI.chat.right.panelTop:Hide()
end
-- set chat visibility -- set chat visibility
pfUI.chat.right:SetAlpha(self.state and 1 or 0) pfUI.chat.right:SetAlpha(self.state and 1 or 0)
+2 -10
View File
@@ -42,11 +42,7 @@ pfUI:RegisterModule("unitxp", function ()
end end
local success, behind = pcall(UnitXP, "behind", "player", "target") local success, behind = pcall(UnitXP, "behind", "player", "target")
if success and behind then this.text:SetShown(success and behind)
this.text:Show()
else
this.text:Hide()
end
end) end)
pfUI.uf.target.behindIndicator = behindFrame pfUI.uf.target.behindIndicator = behindFrame
@@ -76,11 +72,7 @@ pfUI:RegisterModule("unitxp", function ()
end end
local success, inSight = pcall(UnitXP, "inSight", "player", "target") local success, inSight = pcall(UnitXP, "inSight", "player", "target")
if success and inSight == false then this.text:SetShown(success and inSight == false)
this.text:Show()
else
this.text:Hide()
end
end) end)
pfUI.uf.target.losIndicator = losFrame pfUI.uf.target.losIndicator = losFrame