mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-31 16:06:57 +00:00
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:
+7
-23
@@ -414,11 +414,7 @@ pfUI:RegisterModule("actionbar", function ()
|
||||
end
|
||||
|
||||
-- equipped item
|
||||
if IsEquippedAction(sid) and C.bars.showequipped == "1" then
|
||||
self.equipped:Show()
|
||||
else
|
||||
self.equipped:Hide()
|
||||
end
|
||||
self.equipped:SetShown(IsEquippedAction(sid) and C.bars.showequipped == "1")
|
||||
end
|
||||
|
||||
local start, duration, enable, castable, autocast, token
|
||||
@@ -506,11 +502,7 @@ pfUI:RegisterModule("actionbar", function ()
|
||||
self.autocast:Hide()
|
||||
end
|
||||
|
||||
if castable and C.bars.showcastable == "1" then
|
||||
self.autocastable:Show()
|
||||
else
|
||||
self.autocastable:Hide()
|
||||
end
|
||||
self.autocastable:SetShown(castable and C.bars.showcastable == "1")
|
||||
end
|
||||
|
||||
-- keybinds
|
||||
@@ -1116,7 +1108,7 @@ pfUI:RegisterModule("actionbar", function ()
|
||||
end
|
||||
|
||||
-- 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)
|
||||
f.macro:SetFont(font, macro_size, "OUTLINE")
|
||||
f.macro:SetTextColor(unpack(macro_color))
|
||||
@@ -1124,7 +1116,7 @@ pfUI:RegisterModule("actionbar", function ()
|
||||
f.macro:SetJustifyV("BOTTOM")
|
||||
|
||||
-- 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)
|
||||
f.keybind:SetFont(font, bind_size, "OUTLINE")
|
||||
f.keybind:SetTextColor(unpack(bind_color))
|
||||
@@ -1133,7 +1125,7 @@ pfUI:RegisterModule("actionbar", function ()
|
||||
f.keybind:SetNonSpaceWrap(false)
|
||||
|
||||
-- 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)
|
||||
f.count:SetFont(font, count_size, "OUTLINE")
|
||||
f.count:SetTextColor(unpack(count_color))
|
||||
@@ -1232,11 +1224,7 @@ pfUI:RegisterModule("actionbar", function ()
|
||||
-- handle pet bar
|
||||
if i == 12 then
|
||||
-- only show when pet actions exists
|
||||
if PetHasActionBar() or pfUI.unlock and pfUI.unlock:IsShown() then
|
||||
bars[i]:Show()
|
||||
else
|
||||
bars[i]:Hide()
|
||||
end
|
||||
bars[i]:SetShown(PetHasActionBar() or pfUI.unlock and pfUI.unlock:IsShown())
|
||||
|
||||
-- show/hide petbar on petbar updates
|
||||
if init then
|
||||
@@ -1256,11 +1244,7 @@ pfUI:RegisterModule("actionbar", function ()
|
||||
-- handle shapeshift bar
|
||||
elseif i == 11 then
|
||||
-- only show when shapeshifts exist
|
||||
if GetNumShapeshiftForms() > 0 then
|
||||
bars[i]:Show()
|
||||
else
|
||||
bars[i]:Hide()
|
||||
end
|
||||
bars[i]:SetShown(GetNumShapeshiftForms() > 0)
|
||||
|
||||
-- update shapeshift bar when amount of spells changes
|
||||
if init then
|
||||
|
||||
@@ -402,11 +402,7 @@ pfUI:RegisterModule("addonbuttons", function ()
|
||||
-- rescan before deciding whether the panel should be shown by default
|
||||
pfUI.addonbuttons:ProcessButtons()
|
||||
|
||||
if C.abuttons.showdefault == "1" and GetNumButtons() > 0 then
|
||||
pfUI.addonbuttons:Show()
|
||||
else
|
||||
pfUI.addonbuttons:Hide()
|
||||
end
|
||||
pfUI.addonbuttons:SetShown(C.abuttons.showdefault == "1" and GetNumButtons() > 0)
|
||||
|
||||
-- apply workarounds
|
||||
for k, v in pairs(pfUI.addonbuttons.overrides) do
|
||||
|
||||
@@ -86,11 +86,7 @@ pfUI:RegisterModule("autovendor", function ()
|
||||
if not pfMerchantFrame_Update then
|
||||
local pfMerchantFrame_Update = MerchantFrame_Update
|
||||
function _G.MerchantFrame_Update()
|
||||
if MerchantFrame.selectedTab == 1 and C["global"]["autosell"] ~= "1" then
|
||||
autovendor.button:Show()
|
||||
else
|
||||
autovendor.button:Hide()
|
||||
end
|
||||
autovendor.button:SetShown(MerchantFrame.selectedTab == 1 and C["global"]["autosell"] ~= "1")
|
||||
pfMerchantFrame_Update()
|
||||
end
|
||||
end
|
||||
|
||||
+3
-15
@@ -40,11 +40,7 @@ pfUI:RegisterModule("bags", function ()
|
||||
|
||||
-- overwrite some bag functions
|
||||
function _G.OpenAllBags()
|
||||
if pfUI.bag.right:IsShown() then
|
||||
pfUI.bag.right:Hide()
|
||||
else
|
||||
pfUI.bag.right:Show()
|
||||
end
|
||||
pfUI.bag.right:SetShown(not pfUI.bag.right:IsShown())
|
||||
end
|
||||
|
||||
function _G.CloseAllBags()
|
||||
@@ -52,11 +48,7 @@ pfUI:RegisterModule("bags", function ()
|
||||
end
|
||||
|
||||
function _G.ToggleBackpack()
|
||||
if pfUI.bag.right:IsShown() then
|
||||
pfUI.bag.right:Hide()
|
||||
else
|
||||
pfUI.bag.right:Show()
|
||||
end
|
||||
pfUI.bag.right:SetShown(not pfUI.bag.right:IsShown())
|
||||
end
|
||||
|
||||
function _G.OpenBackpack()
|
||||
@@ -1140,11 +1132,7 @@ pfUI:RegisterModule("bags", function ()
|
||||
end)
|
||||
|
||||
frame.bags:SetScript("OnClick", function()
|
||||
if pfUI.bag.left.bagslots:IsShown() then
|
||||
pfUI.bag.left.bagslots:Hide()
|
||||
else
|
||||
pfUI.bag.left.bagslots:Show()
|
||||
end
|
||||
pfUI.bag.left.bagslots:SetShown(not pfUI.bag.left.bagslots:IsShown())
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
@@ -778,7 +778,7 @@ pfUI:RegisterModule("equipmentmanager", function()
|
||||
function UpdatePopouts()
|
||||
local show = PopoutsActive()
|
||||
for _, b in ipairs(popoutButtons) do
|
||||
if show then b:Show() else b:Hide() end
|
||||
b:SetShown(show)
|
||||
end
|
||||
if not show then flyout:Hide() end
|
||||
end
|
||||
@@ -831,7 +831,7 @@ pfUI:RegisterModule("equipmentmanager", function()
|
||||
-- uncommitted user changes show immediately.
|
||||
local setIgnored = selectedSetID and GetEffectiveIgnored(selectedSetID) or {}
|
||||
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
|
||||
|
||||
local hasSelection = selectedSetID and true or false
|
||||
@@ -1170,7 +1170,7 @@ pfUI:RegisterModule("equipmentmanager", function()
|
||||
|
||||
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.locs = {}
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
pfUI:RegisterModule("farmmode", function ()
|
||||
local function ToggleFarmMode()
|
||||
if pfUI.farmmap:IsShown() then
|
||||
pfUI.farmmap:Hide()
|
||||
else
|
||||
pfUI.farmmap:Show()
|
||||
end
|
||||
pfUI.farmmap:SetShown(not pfUI.farmmap:IsShown())
|
||||
end
|
||||
|
||||
local function MoveNodes(layer)
|
||||
|
||||
@@ -37,11 +37,7 @@ pfUI:RegisterModule("gryphons", function ()
|
||||
frame.texture:SetTexCoord(1, 0, 0, 1)
|
||||
end
|
||||
|
||||
if texture then
|
||||
frame:Show()
|
||||
else
|
||||
frame:Hide()
|
||||
end
|
||||
frame:SetShown(texture)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ pfUI:RegisterModule("loothistory", function ()
|
||||
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 isWinner then pf.winmark:Show() else pf.winmark:Hide() end
|
||||
pf.winmark:SetShown(isWinner)
|
||||
end
|
||||
|
||||
local view = CreateScrollBoxListLinearView(2, 2, 4, 4, 2)
|
||||
|
||||
@@ -74,11 +74,7 @@ pfUI:RegisterModule("thirdparty", function()
|
||||
-- show/hide right chatframe
|
||||
if pfUI.chat and C.chat.right.enable == "1" then
|
||||
-- make sure the panel header stays hidden
|
||||
if self.state then
|
||||
pfUI.chat.right.panelTop:Show()
|
||||
else
|
||||
pfUI.chat.right.panelTop:Hide()
|
||||
end
|
||||
pfUI.chat.right.panelTop:SetShown(self.state)
|
||||
|
||||
-- set chat visibility
|
||||
pfUI.chat.right:SetAlpha(self.state and 1 or 0)
|
||||
|
||||
+2
-10
@@ -42,11 +42,7 @@ pfUI:RegisterModule("unitxp", function ()
|
||||
end
|
||||
|
||||
local success, behind = pcall(UnitXP, "behind", "player", "target")
|
||||
if success and behind then
|
||||
this.text:Show()
|
||||
else
|
||||
this.text:Hide()
|
||||
end
|
||||
this.text:SetShown(success and behind)
|
||||
end)
|
||||
|
||||
pfUI.uf.target.behindIndicator = behindFrame
|
||||
@@ -76,11 +72,7 @@ pfUI:RegisterModule("unitxp", function ()
|
||||
end
|
||||
|
||||
local success, inSight = pcall(UnitXP, "inSight", "player", "target")
|
||||
if success and inSight == false then
|
||||
this.text:Show()
|
||||
else
|
||||
this.text:Hide()
|
||||
end
|
||||
this.text:SetShown(success and inSight == false)
|
||||
end)
|
||||
|
||||
pfUI.uf.target.losIndicator = losFrame
|
||||
|
||||
Reference in New Issue
Block a user