Loading...

Tukui Player Combat/Outofcombat show/hide

#1
for MaxUI I'm working on hiding the player and other unitframes out of combat and showing it in combat. But I also want them to show when mousover out of combat.
The next part of the code works for hiding and showing the player frame.

VertAnchorLine Is a small added frame in my UF, all other parts are anchored and/or parented to it. So hiding/showing this makes aeverything else show/hide and is working like I want to.
C["CombatShow"]["Player"] is a config option I added to the tukui config and works without problems.

Code: Select all

local function Player(self)
-- lots of other code to edit looks like HP and mana etc.
	-- vertical anchor line
	local VertAnchorLine = CreateFrame("Frame", "VertAnchorLine", self)
	VertAnchorLine:SetTemplate()
	VertAnchorLine:Size(thickness, 54)
	VertAnchorLine:Point("BOTTOMLEFT", self, "BOTTOMRIGHT", -60, 0)
	VertAnchorLine:SetFrameLevel(2)
	VertAnchorLine:SetFrameStrata("BACKGROUND")
	VertAnchorLine:SetAlpha(1)
	VertAnchorLine:CreateShadow("Default")

	if C["CombatShow"]["Player"] == true then
		local CombatShow = CreateFrame("Frame")
		CombatShow:SetScript("OnEvent", function(self, event,...)
			if event == "PLAYER_ENTERING_WORLD" then
				VertAnchorLine:Hide()

			elseif event == "PLAYER_REGEN_ENABLED" then
				VertAnchorLine:Hide()
			
			elseif event == "PLAYER_REGEN_DISABLED" then
				VertAnchorLine:Show()
			end
		end)
		CombatShow:RegisterEvent("PLAYER_ENTERING_WORLD")
		CombatShow:RegisterEvent("PLAYER_REGEN_DISABLED")
		CombatShow:RegisterEvent("PLAYER_REGEN_ENABLED")	
	end
end
hooksecurefunc(UnitFrames, "Player", Player)
If used the following code to create a highlight function when mousing over my Player UF which also works as I want/expect.

Code: Select all

		-- highlighting unit
		self:HookScript("OnEnter", function(self)
			Health.Backdrop:SetBackdropBorderColor(Health:GetStatusBarColor())
			Power.Backdrop:SetBackdropBorderColor(Power:GetStatusBarColor())
			if C.UnitFrames.Portrait then
				potraitframe:SetBackdropBorderColor(Health:GetStatusBarColor())
			end	
		end)

		self:HookScript("OnLeave", function(self)
			Health.Backdrop:SetBackdropBorderColor(unpack(C["General"]["BorderColor"]))
			Power.Backdrop:SetBackdropBorderColor(unpack(C["General"]["BorderColor"]))
			if C.UnitFrames.Portrait then
				potraitframe:SetBackdropBorderColor(unpack(C["General"]["BorderColor"]))
			end
		end)
If I use something like that for creating a mouseover show/hide function only when PLAYER_REGEN_ENABLED, It isn't working.

tried this:

Code: Select all

	if C["CombatShow"]["Player"] == true then
		local CombatShow = CreateFrame("Frame")
		CombatShow:SetScript("OnEvent", function(self, event,...)
			if event == "PLAYER_ENTERING_WORLD" then
				VertAnchorLine:Hide()

			elseif event == "PLAYER_REGEN_ENABLED" then
				VertAnchorLine:Hide()

				self:HookScript("OnEnter", function()
				VertAnchorLine:Show()
				end)

				self:HookScript("OnLeave", function()
				VertAnchorLine:Hide()
				end)
			
			elseif event == "PLAYER_REGEN_DISABLED" then
				VertAnchorLine:Show()
			end
		end)
		CombatShow:RegisterEvent("PLAYER_ENTERING_WORLD")
		CombatShow:RegisterEvent("PLAYER_REGEN_DISABLED")
		CombatShow:RegisterEvent("PLAYER_REGEN_ENABLED")	
	end
Help or fix is appreciated!
Maximvs-Aszune, MaxUI

Who is online

Users browsing this forum: No registered users and 1 guest