View Single Post
04-14-14, 09:00 AM   #5
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Phanx View Post
All of these lines will break the default UI and spam you with "action blocked" errors:

Code:
MainMenuBar.ClearAllPoints = bottom 
MainMenuBar.SetPoint = bottom

OverrideActionBar.ClearAllPoints = bottom 
OverrideActionBar.SetPoint = bottom

PetBattleFrame.BottomFrame.ClearAllPoints = bottom 
PetBattleFrame.BottomFrame.SetPoint = bottom
You can't override methods on secure frames this way. Even your other idea:

Code:
hooksecurefunc('OverrideActionBar_SetDefaultAnchor', function(self)
	self:SetPoint(("BOTTOM", DataPanel, "TOP", 0, -3)
end)
... will throw errors because -- aside from having an extra parenthesis -- you can't move a secure frame in combat either. You are on the right track, however. You just need to add a combat check to your secure hook:

Code:
hooksecurefunc("OverrideActionBar_SetDefaultAnchor", function(self)
	if not InCombatLockdown() then
		self:SetPoint("BOTTOM", DataPanel, "TOP", 0, -3)
	end
end)
You may also want to add a "queue" so that any frames that were moved during combat (when you can't move them) can be moved after combat ends:

Code:
local queue = {}

local queueHandler = CreateFrame("Frame")
queueHandler:RegisterEvent("PLAYER_REGEN_ENABLED")
queueHandler:SetScript("OnEvent", function(self, event)
	for i = 1, #queue do
		local frame, pointA, anchor, pointB, x, y = unpack(queue[i])
		frame:SetPoint(pointA, anchor, pointB, x, y)
	end
end)

hooksecurefunc("OverrideActionBar_SetDefaultAnchor", function(self)
	if not InCombatLockdown() then
		self:SetPoint("BOTTOM", DataPanel, "TOP", 0, -3)
	else
		tinsert(queue, { self, "BOTTOM", DataPanel, "TOP", 0, -3 })
	end
end)
Your other option, as you said, would be to hide your data panel while in a vehicle:

Code:
DataPanel:RegisterUnitEvent("UNIT_ENTERING_VEHICLE", "player")
DataPanel:RegisterUnitEvent("UNIT_EXITED_VEHICLE", "player")

DataPanel:SetScript("OnEvent", function(self, event, ...)
	if event == "UNIT_ENTERING_VEHICLE" then
		self:Hide()
	elseif event == "UNIT_EXITED_VEHICLE" then
		self:Show()
	end
end)
Again Thank You for the help,

Beings that Vehicles and Pet Battle both hide the mainbar I went with the hide option so I had to modify the code a little.

Code:
			-- Hide Panels When in a Vehicle or Pet Battle
			MainPanel:RegisterUnitEvent("UNIT_ENTERING_VEHICLE", "player")
			MainPanel:RegisterUnitEvent("UNIT_EXITED_VEHICLE", "player")
			MainPanel:RegisterUnitEvent("PET_BATTLE_OPENING_START")
			MainPanel:RegisterUnitEvent("PET_BATTLE_CLOSE")

			MainPanel:SetScript("OnEvent", function(self, event, ...)
				if event == "UNIT_ENTERING_VEHICLE" or event == "PET_BATTLE_OPENING_START" then
					self:Hide()
				elseif event == "UNIT_EXITED_VEHICLE" or event == "PET_BATTLE_CLOSE" then
					self:Show()
				end
			end)
It hides the panel in both vehicle and pet battles, although the tooltips still show for each stat when moused over. Would I have to goto the tooltip part of each stat and add a event=="" to those to stop them from showing?

I currently have "if not InCombatLockdown() then" to stop tooltips in combat. Is there a "if not InVehicle" or "if not InPetBattle"

Thanks again Phanx.

Coke
  Reply With Quote