Thread Tools Display Modes
11-24-14, 10:28 PM   #1
Sasenna
A Murloc Raider
 
Sasenna's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 7
Player Frame and Entering/Leaving Vehicle

Player Frame resets to TOPLEFT when entering a vehicle. I want the player frame to be able to make it stay in the custom position.
Code:
	-------------------------------------------------------
	-- Player Frame
	-------------------------------------------------------
	local function Player_Update()
		PlayerFrame:ClearAllPoints()
		PlayerFrame:SetPoint(a1, af1, a1, x1, y1)
		PlayerFrame:SetScale(scaleOut)
		--PlayerFrame.SetPoint = function()end  -- Not allow playerframe to move while in vehicle, also wont allow combat moving
	end
	local f = CreateFrame("Frame", nil, UIParent)
	f:RegisterEvent("PLAYER_ENTERING_WORLD")
	f:RegisterEvent("PLAYER_REGEN_ENABLED")
--[[
	f:RegisterEvent("PLAYER_GAINS_VEHICLE_DATA")
	f:RegisterEvent("PLAYER_LOSES_VEHICLE_DATA")
	f:RegisterEvent("PLAYER_REGEN_ENABLED")
	f:RegisterEvent("UNIT_ENTERING_VEHICLE")
	f:RegisterEvent("UNIT_ENTERED_VEHICLE")
	f:RegisterEvent("UNIT_EXITING_VEHICLE")
	f:RegisterEvent("UNIT_EXITED_VEHICLE")
--]]
	f:SetScript("OnEvent", Player_Update)
	
	-------------------------------------------------------
	-- Target Frame
	-------------------------------------------------------
	local function Target_Update()
		TargetFrame:ClearAllPoints()
		TargetFrame:SetPoint(a3, af3, a3, x3, y3)
		TargetFrame:SetScale(scaleOut)
		--TargetFrame:SetAlpha(0.65) -- Opacity of the Frame
	end
	local f = CreateFrame("Frame", nil, UIParent)
	f:RegisterEvent("PLAYER_ENTERING_WORLD")
	f:RegisterEvent("PLAYER_REGEN_ENABLED")
	f:SetScript("OnEvent", Target_Update)
Everything commented out I have tried but none of them stop the player frame from resetting.
Code:
PlayerFrame.SetPoint = function()end
Does work but I also have my player and target frames scale larger when I enter and leave combat. With that enable they no longer can be updated at all.

Combat move code if needed:
Code:
	local function Player_InCombat_Update()
		UIParent:SetAlpha(UIalphaIN)
		PlayerFrame:ClearAllPoints()
		PlayerFrame:SetPoint(a2, af2, a2, x2, y2)
		PlayerFrame:SetScale(scaleIn)
		
		TargetFrame:ClearAllPoints()
		TargetFrame:SetPoint(a4, af4, a4, x4, y4)
		TargetFrame:SetScale(scaleIn)

	end
	local f = CreateFrame("Frame", nil, UIParent)
	f:RegisterEvent("PLAYER_REGEN_DISABLED")
	f:SetScript("OnEvent", Player_InCombat_Update)
Variable info:
Code:
  ---------------------------------------------
  --  COMBAT FADING and SCALING
  ---------------------------------------------
  
  -- Combat Fading
  UIalphaIN  = 0.65 -- Opacity of ALL frames IN of Combat
  UIalphaOUT = 1.00 -- Opacity of ALL frames OUT of Combat
  
  -- Combat Scaling
  scaleOut = 1.00 -- Scale of Player/Target Frames OUT of combat
  scaleIn  = 1.25 -- Scale of Player/Target Frames IN combat // Set to same as scaleOut to NOT have scaling change
  
  -- Focus Frame Scales
  fScale = 1.15 -- Scale of the Focus Frame
  
  ---------------------------------------------
  --  UNITFRAMES
  ---------------------------------------------
    
  -- Player Frame Placement OUT of Combat
  a1  = "TOPLEFT"     -- Anchor Point of Frame
  af1 = ActionButton1 -- Anchor Frame
  x1  = -175          -- x axis movement
  y1  = 200           -- y axis movement
  
  -- Player Frame Placement IN of Combat
  a2  = "CENTER"      -- Anchor Point of Frame
  af2 = UIParent      -- Anchor Frame
  x2  = -315          -- x axis movement
  y2  = 0             -- y axis movement
  
    -- Target Frame Placement OUT of Combat
  a3  = "TOPRIGHT"    -- Anchor Point of Frame
  af3 = ActionButton12-- Anchor Frame
  x3  = 175           -- x axis movement
  y3  = 200           -- y axis movement
  
  -- Target Frame Placement IN of Combat
  a4  = "CENTER"      -- Anchor Point of Frame
  af4 = UIParent      -- Anchor Frame
  x4  = 315           -- x axis movement
  y4  = 0             -- y axis movement
  
  -- Focus Frame Placement
  a5  = "TOPRIGHT"    -- Anchor Point of Frame
  af5 = TargetFrame   -- Anchor Frame
  x5  = 175           -- x axis movement
  y5  = 100           -- y axis movement
Once I attack anything in a vehicle the frames move to the correct locations. Just the initial enter/leave vehicle has the frames reset to default positions.

Pictures
__________________
l SasUI l - Blizzard Like l Sas Diablo l - Alteration of l RothUI (Diablo) l

Last edited by Sasenna : 11-24-14 at 10:46 PM. Reason: Added pictures
  Reply With Quote
11-25-14, 01:55 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
1. You can't overwrite methods on secure frames, or you taint the whole thing.

2. Is there some reason why you can't just move it yourself in-game? Right-click, select "Unlock frame", drag to the desired location, right-click again, select "Lock frame". If you actually need to move it from an addon for some reason, you should check what functions are called by the default UI code when moving it in-game, and mimic that in your addon, so the game will save the correct position.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
11-25-14, 01:58 PM   #3
Sasenna
A Murloc Raider
 
Sasenna's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 7
Thanks for the reply back that helped me find the solution. All was missing as PlayerFrame:SetUserPlaced(true) in the Player_Update Function.
Code:
	local function Player_Update()
		PlayerFrame:ClearAllPoints()
		PlayerFrame:SetPoint(a1, af1, a1, x1, y1)
		PlayerFrame:SetScale(scaleOut)
		PlayerFrame:SetUserPlaced(true) -- Entering Vehicle no longer moves the frame 
		--PlayerFrame.SetPoint = function()end  -- Not allow playerframe to move while in vehicle, also wont allow combat moving
	end
	local f = CreateFrame("Frame", nil, UIParent)
	f:RegisterEvent("PLAYER_ENTERING_WORLD")
	f:RegisterEvent("PLAYER_REGEN_ENABLED")
	f:SetScript("OnEvent", Player_Update)
Reason I wanted it like this as apposed to just placing manually is the amount of characters I'd have to do it to. Also I'm very picky as far as lining them up.
Originally Posted by Phanx View Post
1. You can't overwrite methods on secure frames, or you taint the whole thing.

2. Is there some reason why you can't just move it yourself in-game? Right-click, select "Unlock frame", drag to the desired location, right-click again, select "Lock frame". If you actually need to move it from an addon for some reason, you should check what functions are called by the default UI code when moving it in-game, and mimic that in your addon, so the game will save the correct position.
__________________
l SasUI l - Blizzard Like l Sas Diablo l - Alteration of l RothUI (Diablo) l
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Player Frame and Entering/Leaving Vehicle


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off