Thread Tools Display Modes
03-29-12, 01:50 AM   #1
Sasenna
A Murloc Raider
 
Sasenna's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 7
How to stop MultiBarRight from resetting?

SOLVED: Took all previous code and threw it out the window. From researching other people's code I eventually got it to work. Most useful code was Zork's for his rQuestFrameWatcher.
Lua Code:
  1. -------------------------------------------------------
  2.     -- Init
  3.     -------------------------------------------------------
  4.  
  5.     local _G = _G
  6.  
  7.     -------------------------------------------------------
  8.     -- Action Bars
  9.     -------------------------------------------------------
  10.     --MainBar
  11.     MainMenuBar:SetScale(0.75)
  12.     VehicleMenuBar:SetScale(0.75)
  13.    
  14.     local function init()
  15.         local mbr = _G['MultiBarRight']
  16.             mbr:SetClampedToScreen(false)
  17.             mbr:SetMovable(1)
  18.             mbr:SetUserPlaced(true)
  19.             mbr:ClearAllPoints()   
  20.             mbr.ClearAllPoints = function() end
  21.             mbr:SetPoint("RIGHT", -28, -4)
  22.             mbr:SetScale(0.68)
  23.             mbr.SetPoint = function() end
  24.         end
  25.  
  26.         local f = CreateFrame("Frame")
  27.  
  28.         f:SetScript("OnEvent", function(self, event)
  29.         if(event=="PLAYER_LOGIN") then
  30.             init()
  31.         end
  32.     end)
  33.  
  34.     f:RegisterEvent("PLAYER_LOGIN")

Thanks again.


How can I make the MultiRightBar stop resetting itself when going through instance zones? Bar is setup correctly when logging into the world, taking portals from mages and zoning into outland/northrend/cata zones. But when entering deeprum tram, instance portals or raids the bar is reset. Not getting any LUA errors. Reloading UI sets bar to how it is supposed to be.

PreRight Bar Move


Post Right Bar Move:


Code:
	-------------------------------------------------------
	-- Frames Blocked from Moving
	-------------------------------------------------------
	UIPARENT_MANAGED_FRAME_POSITIONS["MultiBarRight"] = nil
	UIPARENT_MANAGED_FRAME_POSITIONS["MultiBarLeft"] = nil
	UIPARENT_MANAGED_FRAME_POSITIONS["MultiBarBottomLeft"] = nil
	UIPARENT_MANAGED_FRAME_POSITIONS["MultiBarBottomRight"] = nil
	UIPARENT_MANAGED_FRAME_POSITIONS["MainMenuBar"] = nil

	--UIPARENT_MANAGED_FRAME_POSITIONS["PetActionBarFrame"] = nil
	--UIPARENT_MANAGED_FRAME_POSITIONS["ShapeshiftBarFrame"] = nil
	UIPARENT_MANAGED_FRAME_POSITIONS["PossessBarFrame"] = nil
	UIPARENT_MANAGED_FRAME_POSITIONS["CastingBarFrame"] = nil
	UIPARENT_MANAGED_FRAME_POSITIONS["MainMenuBarPerformanceBarFrame"] = nil
	UIPARENT_MANAGED_FRAME_POSITIONS["MainMenuBarPerformanceBarButton"] = nil
	UIPARENT_MANAGED_FRAME_POSITIONS["BonusActionBarFrame"] = nil

	-------------------------------------------------------
	-- Player Frame
	-------------------------------------------------------
	local function Player_Update()
		PlayerFrame:ClearAllPoints()
		PlayerFrame:SetPoint("TOP", "BuffFrame", "TOP", 125, 150)
		PlayerFrame:SetScale(1.25)
		--PlayerFrame:SetAlpha(0.65) -- Opacity of the Frame
	end
	local f = CreateFrame("Frame", nil, UIParent)
	f:RegisterEvent("PLAYER_ENTERING_WORLD")
	f:SetScript("OnEvent", Player_Update)
		
	-------------------------------------------------------
	-- Target Frame
	-------------------------------------------------------
	local function Target_Update()
		TargetFrame:ClearAllPoints()
		TargetFrame:SetPoint("RIGHT", "PlayerFrame", "RIGHT", 355, 0)
		TargetFrame:SetScale(1.25)
		--TargetFrame:SetAlpha(0.65) -- Opacity of the Frame
	end
	local f = CreateFrame("Frame", nil, UIParent)
	f:RegisterEvent("PLAYER_ENTERING_WORLD")
	f:SetScript("OnEvent", Target_Update)
	
	-------------------------------------------------------
	-- RuneBar Frame
	-------------------------------------------------------
	local function Rune_Update()
		--RuneFrame:Show()
		RuneFrame:ClearAllPoints()
		RuneFrame:SetPoint("TOP", "PlayerFrame", "BOTTOM", 53, 32)
		RuneFrame:SetScale(1.25)
		for i = 1, 6 do
		local frame = _G["RuneButtonIndividual"..i]
			frame:EnableMouse(false)
		end
	end
	local f = CreateFrame("Frame", nil, UIParent)
	f:RegisterEvent("PLAYER_ENTERING_WORLD")
	f:SetScript("OnEvent", Rune_Update)
	
	-------------------------------------------------------
	-- Minimap
	-------------------------------------------------------
	MinimapCluster:ClearAllPoints()
	MinimapCluster:SetPoint("BOTTOMRIGHT", -15, -10)
	MinimapCluster:SetScale(1.25)
	
	MiniMapLFGFrame:ClearAllPoints()
	MiniMapLFGFrame:SetPoint("TOPLEFT", Minimap, -2, -2)
	MiniMapLFGFrame:SetScale(0.93)
	--MiniMapLFGFrameBorder:SetAlpha(0)
	
	MiniMapBattlefieldFrame:ClearAllPoints()
	MiniMapBattlefieldFrame:SetPoint("TOPLEFT", Minimap, -2, 1)
	MiniMapLFGFrame:SetScale(0.93)
	
	Minimap:SetMaskTexture("Interface\\CharacterFrame\\TempPortraitAlphaMask")
	
	Minimap:EnableMouseWheel(true)
	Minimap:SetScript("OnMouseWheel", function(self, arg1)
		if (arg1 > 0) then
			Minimap_ZoomIn()
		else
			Minimap_ZoomOut()
		end
	end)
	
	-------------------------------------------------------
	-- Party
	-------------------------------------------------------
	PartyMemberFrame1:SetScale(1.25)
	PartyMemberFrame2:SetScale(1.25)
	PartyMemberFrame3:SetScale(1.25)
	PartyMemberFrame4:SetScale(1.25)
	
	-------------------------------------------------------
	-- Action Bars
	-------------------------------------------------------
	--MainBar
	MainMenuBar:SetScale(0.75)
	VehicleMenuBar:SetScale(0.75)
	
	--RightBar
	MultiBarRight:ClearAllPoints()
	MultiBarRight:SetPoint("RIGHT", -28, -4)
	MultiBarRight:SetScale(0.68)
	
	--[[
	local function RightBar_Update()
		MultiBarRight:ClearAllPoints()
		MultiBarRight:SetPoint("RIGHT", -28, -4)
		MultiBarRight:SetScale(0.62)	
	end
	local f = CreateFrame("Frame", nil, UIParent)
	f:RegisterEvent("PLAYER_ENTERING_WORLD")
	f:SetScript("OnEvent", RightBar_Update)
	--]]
Thanks,
~Sas
__________________
l SasUI l - Blizzard Like l Sas Diablo l - Alteration of l RothUI (Diablo) l

Last edited by Sasenna : 03-30-12 at 12:50 AM. Reason: Solved
  Reply With Quote
03-29-12, 02:36 AM   #2
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Did you comment out that bit of code at the end for a reason? Because that might very well do it, if it's reset upon zoning through an instance that means it resets on PLAYER_ENTERING_WORLD and you need to register that event to reapply your changes.
  Reply With Quote
03-29-12, 10:27 AM   #3
Sasenna
A Murloc Raider
 
Sasenna's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 7
I commented out the last bit of code because it was still resetting itself through instances.
__________________
l SasUI l - Blizzard Like l Sas Diablo l - Alteration of l RothUI (Diablo) l
  Reply With Quote
03-30-12, 12:11 AM   #4
Sasenna
A Murloc Raider
 
Sasenna's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 7
Update

Can now make the MultiBarRight return to the correct position after exiting an instance, but entering still resets it to Blizz default.

Had to use RegisterEvent("WORLD_MAP_UPDATE"). Using the Deeprun Tram as a test for instancing. It does reset upon leaving the instance but is not 100%, sometimes have to exit the tram a few times for it to change the bar position.

Had in a counter to see how many times the code is gone through, reloading Ui goes through it twice. Entering/Leaving an instance goes through the code 14 times.

Using http://www.wowpedia.org/Events/Instance as a basis to work with.

"PLAYER_ENTERING_WORLD"
Category: System,Player,Instance

Fired when the player enters the world, enters/leaves an instance, or respawns at a graveyard. Also fires any other time the player sees a loading screen.

To check if the player is entering an instance, check GetPlayerMapPosition to see if both X and Y are zero.

Correction on the above comment: When PLAYER_ENTERING_WORLD fires, you'll notice that WORLD_MAP_UPDATE fires just before it. My instincts tell that leaving an instance puts the player in void space momentarily. So for the case that you are entering AND leaving an instance, GetPlayerMapPosition always returns the coordinates [0,0] and hence there is no way to determine using the event PLAYER_ENTERING_WORLD if the player is entering an instance or not. When leaving an instance the following events fire (ignoring party/raid events).
WORLD_MAP_UPDATE
PLAYER_ENTERING_WORLD
WORLD_MAP_UPDATE <--- Player coordinates are non-zero here
Instances do have coordinates for units once the second WORLD_MAP_UPDATE event has fired. For the case of entering a battleground such as WSG, WORLD_MAP_UPDATE won't fire until you leave Silverwing Hold or Warsong Lumber Mill and you are outside. --Salanex
Code Update:
Lua Code:
  1. -------------------------------------------------------
  2.     -- Frames Blocked from Moving
  3.     -------------------------------------------------------
  4.     UIPARENT_MANAGED_FRAME_POSITIONS["MultiBarRight"] = nil
  5.  
  6.     -------------------------------------------------------
  7.     -- Action Bars
  8.     -------------------------------------------------------
  9.     --MainBar
  10.     MainMenuBar:SetScale(0.75)
  11.     VehicleMenuBar:SetScale(0.75)
  12.    
  13.     --RightBar
  14.     local i = 0
  15.     local function RightBar_Update()
  16.         MultiBarRight:ClearAllPoints()
  17.         print("After Clear")
  18.         MultiBarRight:SetPoint("RIGHT", "UIParent", "RIGHT", -28, -4)
  19.         print("After SetPoint")
  20.         MultiBarRight:SetScale(0.68)
  21.         print("After Scale")
  22.         i = i + 1
  23.         print("Number of passes: "..i)
  24.         return i
  25.     end
  26.     local f = CreateFrame("Frame", nil, UIParent)
  27.     f:RegisterEvent("WORLD_MAP_UPDATE")
  28.     print("World Map Update")
  29.     f:RegisterEvent("PLAYER_ENTERING_WORLD")
  30.     print("Player Entered World")
  31.     f:SetScript("OnEvent", RightBar_Update)

Its as if the reference point and y axis is being ignored, x axis is correct.

Thanks for any help,
~Sas
__________________
l SasUI l - Blizzard Like l Sas Diablo l - Alteration of l RothUI (Diablo) l
  Reply With Quote
03-30-12, 01:21 AM   #5
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Important notice. When using UserPlaced you must not call your function on PLAYER_LOGIN event. That will reset the SetPoint saved in the layout-local.txt.

I have a tutorial for such a drag functionality here:
http://www.wowinterface.com/forums/s...ad.php?t=38484

You need to call SetPoint() right when the code is loaded.
Blizzard rewrites that SetPoint() later with the value from the layout-local.txt.
But if you call SetPoint() inside the PLAYER_LOGIN event you will reset your values. If you do not want to move your frame ingame at all that's ok. Otherwise your moved frame would reset on every loadup.

Another important notice. Do not use "object.SetPoint = function() end" this will most likely cause taints and block your code.

Solution. You cannot change the behaviour of the right bar, but your can reanchor all the buttons inside that bar. That's what I'm doing here.
http://code.google.com/p/rothui/sour.../bars/bar4.lua

That solution works perfectly. Just reparent the bar to a new frame (that has your move functionality) and change the SetPoint of the first actionbutton.

In fact...all you have to do is to reanchor the first button. All other buttons are already anchored to that.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 03-30-12 at 02:43 AM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » How to stop MultiBarRight from resetting?


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