I changed the way you were hiding level text to a more permanent solution.
I commented out the line
Code:
TargetFrameSpellBar:SetParent(UIParent)
because is was causing an error for me. It also had a typo "UiParent" but maybe that is correct for your setup.
I used the code I posted in the other thread as a base and modified from there:
Code:
local frame, forceShow, inCombat, queue = CreateFrame("Frame")
local mayShowPetFrame, playerHasTarget = true
local function UpdatePetFrame()
if not inCombat then
local frame = PetFrame
local unit = frame.unit
frame:SetShown(mayShowPetFrame and UnitExists(unit) and (forceShow or playerHasTarget or (UnitHealth(unit) < UnitHealthMax(unit))))
end
end
local function UpdatePlayerFrame()
if not inCombat then
local frame = PlayerFrame
local unit = frame.unit
frame:SetShown(forceShow or playerHasTarget or (UnitHealth(unit) < UnitHealthMax(unit)))
end
end
local function DisableShowMode()
frame:RegisterUnitEvent("UNIT_HEALTH", "player", "pet", "vehicle")
frame:RegisterUnitEvent("UNIT_MAXHEALTH", "player", "pet", "vehicle")
if inCombat then
queue = nil
end
end
local function EnableShowMode(override)
frame:UnregisterEvent("UNIT_HEALTH")
frame:UnregisterEvent("UNIT_MAXHEALTH")
if not inCombat or override then
PlayerFrame:Show()
PetFrame:SetShown(mayShowPetFrame and UnitExists(PetFrame.unit))
else
queue = EnableShowMode
end
end
frame:SetScript("OnEvent", function(self, event, unit)
if event == "UNIT_HEALTH" or event == "UNIT_MAXHEALTH" then
if unit == PlayerFrame.unit then
UpdatePlayerFrame()
elseif unit == PetFrame.unit then
UpdatePetFrame()
end
return
elseif event == "PLAYER_TARGET_CHANGED" then
playerHasTarget = UnitExists("target")
elseif event == "PLAYER_REGEN_DISABLED" then
inCombat = true
EnableShowMode(true)
elseif event == "PLAYER_REGEN_ENABLED" then
inCombat = false
(queue or DisableShowMode)()
queue = nil
else
mayShowPetFrame = UnitIsVisible(PetFrame.unit) and PetUsesPetFrame() and not PlayerFrame.vehicleHidesPet
end
UpdatePlayerFrame()
UpdatePetFrame()
end)
frame:RegisterEvent("PET_UI_UPDATE")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:RegisterEvent("PLAYER_REGEN_DISABLED")
frame:RegisterEvent("PLAYER_REGEN_ENABLED")
frame:RegisterEvent("PLAYER_TARGET_CHANGED")
frame:RegisterUnitEvent("UNIT_ENTERED_VEHICLE", "player")
frame:RegisterUnitEvent("UNIT_EXITED_VEHICLE", "player")
frame:RegisterEvent("UNIT_PET", "player")
DisableShowMode()
function ToggleUnitFrameForceShow()
forceShow = not forceShow
if forceShow then
EnableShowMode()
else
DisableShowMode()
UpdatePlayerFrame()
UpdatePetFrame()
end
end
--[=[---------------------------------------------------------------------------
Other tweaks
-----------------------------------------------------------------------------]=]
CHAT_TAB_SHOW_DELAY = 0
CHAT_TAB_HIDE_DELAY = 0
CHAT_FRAME_FADE_TIME = 0
CHAT_FRAME_FADE_OUT_TIME = 0
DEFAULT_CHATFRAME_ALPHA = 0
ChatFrame1:SetTimeVisible(5)
ChatFrame1:SetFadeDuration(3)
GameTimeFrame:SetParent(UIParent)
GameTimeFrame:SetAlpha(0.4)
GarrisonLandingPageMinimapButton:SetParent(UIParent)
GarrisonLandingPageMinimapButton:SetAlpha(0.4)
MiniMapMailFrame:SetParent(UIParent)
MiniMapMailFrame:SetAlpha(0.4)
MiniMapTracking:SetParent(UIParent)
MiniMapTracking:SetAlpha(0.4)
PetFrameManaBar:HookScript("OnShow", PetFrameManaBar.Hide)
PetFrameTexture:Hide()
PlayerFrameTexture:SetAlpha(0)
QueueStatusMinimapButton:SetParent(UIParent)
QueueStatusMinimapButton:SetAlpha(0.4)
--TargetFrameSpellBar:SetParent(UIParent)
TargetFrameTextureFrameTexture:Hide()
do
local SetZeroAlpha = function(self) self:SetAlpha(0) end
hooksecurefunc(PlayerLevelText, "SetVertexColor", SetZeroAlpha)
hooksecurefunc(TargetFrameTextureFrameLevelText, "SetVertexColor", SetZeroAlpha)
hooksecurefunc(FocusFrameTextureFrameLevelText, "SetVertexColor", SetZeroAlpha)
end
The macro text to force showing PlayerFrame and PetFrame (if applicable) without having a target is:
Code:
/run ToggleUnitFrameForceShow()