Thread Tools Display Modes
09-15-09, 08:35 PM   #1
Laurent
A Deviate Faerie Dragon
 
Laurent's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 12
Dependency Conflict

Hey I'm currently making a mod, well its more like a script, that configures the default MainMenuBar into a config I like. I'm having Issues with moving the menu buttons around. First of all here's teh code for moving the buttons:

Code:
	-- micro menu buttons
	QuestLogMicroButton:ClearAllPoints();
	QuestLogMicroButton:SetPoint("BOTTOMLEFT", "ActionButton12", "BOTTOMRIGHT", 3, -0);

	TalentMicroButton:ClearAllPoints();
	TalentMicroButton:SetPoint("BOTTOM", "QuestLogMicroButton", "TOP", 0, -20);

	CharacterMicroButton:ClearAllPoints();
	CharacterMicroButton:SetPoint("BOTTOM", "TalentMicroButton", "TOP", 0, -20);
	
	MainMenuMicroButton:ClearAllPoints();
	MainMenuMicroButton:SetPoint("LEFT", "QuestLogMicroButton", "RIGHT", 3, 0);

	SocialsMicroButton:ClearAllPoints();
	SocialsMicroButton:SetPoint("BOTTOM", "MainMenuMicroButton", "TOP", 0, -20);
		
	SpellbookMicroButton:ClearAllPoints();
	SpellbookMicroButton:SetPoint("BOTTOM", "SocialsMicroButton", "TOP", 0, -20);
	

	LFGMicroButton:Hide();
	PVPMicroButton:Hide();
	AchievementMicroButton:Hide();
	HelpMicroButton:Hide();
And that works, it moves the buttons around to where i like them and hides the buttons i never use but, it throws this error:

Code:
Message: Interface\\FrameXML\\MainMenuBarMicroButtons.lua:171: AchievementMicroButton:SetPoint(): TalentMicroButton is dependent on this
Time: 09/15/09 20:31:07\nCount: 1
Stack: [string \"Interface\\FrameXML\\BasicControls.xml:<Scrip...\"]:18: in function <[string \"Interface\\FrameXML\\BasicControls.xml:<Scrip...\"]:4>
[C]: ?
[C]: in function `SetPoint'
Interface\\FrameXML\\MainMenuBarMicroButtons.lua:171: in function `UpdateTalentButton'
Interface\\FrameXML\\MainMenuBarMicroButtons.lua:159: in function <Interface\\FrameXML\\MainMenuBarMicroButtons.lua:152>

Locals: (*temporary) = AchievementMicroButton {
 0 = <userdata>
}
(*temporary) = \"BOTTOMLEFT\"
(*temporary) = \"TalentMicroButton\"
(*temporary) = \"BOTTOMRIGHT\"
(*temporary) = -2
(*temporary) = 0
"
Any ideas why this is thrown?
__________________




  Reply With Quote
09-15-09, 09:03 PM   #2
Bruners
A Flamescale Wyrmkin
 
Bruners's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 125
When you hide a frame like that you remove the possibility for other frames to anchor to them, you are hiding a frame thats in the default UI and could be needed for more stuff than you know about.

You should find another way to do this without using the Hide() function, maby you can position the frames off the screen or maby use the SetAlpha() function ?
  Reply With Quote
09-16-09, 07:42 AM   #3
Laurent
A Deviate Faerie Dragon
 
Laurent's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 12
Ok I tried implementing :

Code:
LFGMicroButton:ClearAllPoints();
	LFGMicroButton:SetPoint("BOTTOM", "UIParent", "TOP", 0, 0);

	
	PVPMicroButton:ClearAllPoints();
	PVPMicroButton:SetPoint("BOTTOM", "UIParent", "TOP", 0, 0);
	
	AchievementMicroButton:ClearAllPoints();
	AchievementMicroButton:SetPoint("BOTTOM", "UIParent", "TOP", 0, 0);
	
	HelpMicroButton:ClearAllPoints();
	HelpMicroButton:SetPoint("BOTTOM", "UIParent", "TOP", 0, 0);
But it still throws this error:

Code:
Message: Interface\FrameXML\MainMenuBarMicroButtons.lua:171: AchievementMicroButton:SetPoint(): TalentMicroButton is dependent on this
Time: 09/16/09 07:40:17
Count: 1
Stack: [string "Interface\FrameXML\BasicControls.xml:<Scrip..."]:18: in function <[string "Interface\FrameXML\BasicControls.xml:<Scrip..."]:4>
[C]: ?
[C]: in function `SetPoint'
Interface\FrameXML\MainMenuBarMicroButtons.lua:171: in function `UpdateTalentButton'
Interface\FrameXML\MainMenuBarMicroButtons.lua:159: in function <Interface\FrameXML\MainMenuBarMicroButtons.lua:152>

Locals: (*temporary) = AchievementMicroButton {
 0 = <userdata>
}
(*temporary) = "BOTTOMLEFT"
(*temporary) = "TalentMicroButton"
(*temporary) = "BOTTOMRIGHT"
(*temporary) = -2
(*temporary) = 0
I'm at a loss
__________________




  Reply With Quote
09-16-09, 11:56 AM   #4
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Originally Posted by Bruners View Post
When you hide a frame like that you remove the possibility for other frames to anchor to them
This is not true.

The problem is that AchievementMicroButton_Update anchors QuestLogMicroButton to AchievementMicroButton and UpdateTalentButton anchors AchievementMicroButton to TalentMicroButton. Since Blizzard doesn't call ClearAllPoints before calling SetPoint (didn't really need to) and you are anchoring TalentMicroButton to QuestLogMicroButton in your code it creates a circular logic issue with respect to anchoring.

The easiest solution would be just to do something like:

AchievementMicroButton_Update = function() end
  Reply With Quote
09-16-09, 12:18 PM   #5
Laurent
A Deviate Faerie Dragon
 
Laurent's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 12
Ah thank you very much, I got it kluged together now. Its not pretty but it works and doesn't throw any errors. I doubt its very efficient cause I'm new to coding in general. Here's what I got for code:

Code:
function OnLoad()
	this:RegisterEvent("PLAYER_ENTERING_WORLD");
	this:RegisterEvent("VARIABLES_LOADED");
	
	if( DEFAULT_CHAT_FRAME ) then
		DEFAULT_CHAT_FRAME:AddMessage("CleanBarBare has been successfully loaded...", 0.0, 1.0, 1.0);
	end
		
end

AchievementMicroButton_Update = function() 

	QuestLogMicroButton:ClearAllPoints();
	AchievementMicroButton:ClearAllPoints();
	TalentMicroButton:ClearAllPoints();
	
end

UpdateTalentButton = function()

	QuestLogMicroButton:ClearAllPoints();
	AchievementMicroButton:ClearAllPoints();
	TalentMicroButton:ClearAllPoints();

end

function DoYourThing()

	BarPlacement();
	MainMenuBar:ClearAllPoints();
	MainMenuBar:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", -0, 0);
	
	
	-- micro menu buttons
		AchievementMicroButton:ClearAllPoints();
	
		QuestLogMicroButton:SetPoint("BOTTOMLEFT", "ActionButton12", "BOTTOMRIGHT", 3, -0);
			AchievementMicroButton:Hide();
	
	LFGMicroButton:ClearAllPoints();
	LFGMicroButton:SetPoint("BOTTOM", "UIParent", "TOP", 0, 0);
	--LFGMicroButton:Hide();
	
	PVPMicroButton:ClearAllPoints();
	PVPMicroButton:SetPoint("BOTTOM", "UIParent", "TOP", 0, 0);
	--PVPMicroButton:Hide();
		
	HelpMicroButton:ClearAllPoints();
	HelpMicroButton:SetPoint("BOTTOM", "UIParent", "TOP", 0, 0);
	--HelpMicroButton:Hide();
	
	TalentMicroButton:ClearAllPoints();
	TalentMicroButton:SetPoint("BOTTOM", "QuestLogMicroButton", "TOP", 0, -20);

	CharacterMicroButton:ClearAllPoints();
	CharacterMicroButton:SetPoint("BOTTOM", "TalentMicroButton", "TOP", 0, -20);
	
	MainMenuMicroButton:ClearAllPoints();
	MainMenuMicroButton:SetPoint("LEFT", "QuestLogMicroButton", "RIGHT", 3, 0);

	SocialsMicroButton:ClearAllPoints();
	SocialsMicroButton:SetPoint("BOTTOM", "MainMenuMicroButton", "TOP", 0, -20);
		
	SpellbookMicroButton:ClearAllPoints();
	SpellbookMicroButton:SetPoint("BOTTOM", "SocialsMicroButton", "TOP", 0, -20);
	

		
	-- page turn buttons
	
	MainMenuBarPageNumber:Hide();
	ActionBarUpButton:Hide();
	ActionBarDownButton:Hide();
	
	-- shapeshift bar art
	
	ShapeshiftBarLeft:Hide();
	ShapeshiftBarRight:Hide();
	ShapeshiftBarMiddle:Hide();
	
	-- bags
		
	MainMenuBarBackpackButton:Hide();
	CharacterBag0Slot:Hide();
	CharacterBag1Slot:Hide();
	CharacterBag2Slot:Hide();
	CharacterBag3Slot:Hide();
	KeyRingButton:Hide();
	
	--art
	
	MainMenuBarTexture0:Hide();
	MainMenuBarTexture1:Hide();
	MainMenuBarTexture2:Hide();
	MainMenuBarTexture3:Hide();
	SlidingActionBarTexture0:Hide();
	SlidingActionBarTexture1:Hide();
	ShapeshiftBarLeft:Hide();
	ShapeshiftBarRight:Hide();
	ShapeshiftBarMiddle:Hide();
	
	-- rep and xp bars
	
	MainMenuBarLeftEndCap:Hide()
	MainMenuBarRightEndCap:Hide();
	ExhaustionTick:Hide();
	ExhaustionLevelFillBar:Hide();
	MainMenuExpBar:Hide();
	MainMenuBarMaxLevelBar:Hide();
	ReputationWatchBar:Hide();
	

	
		
end

function BarPlacement()



		MultiBarBottomLeft:ClearAllPoints();
		MultiBarBottomLeft:SetPoint("BOTTOMLEFT", "ActionButton1", "TOPLEFT", -0, 5);
		MultiBarBottomRight:ClearAllPoints();
		MultiBarBottomRight:SetPoint("BOTTOMLEFT", "MultiBarBottomLeftButton1", "TOPLEFT", -0, 5);

	
	MultiBarBottomLeft:Show(); MultiBarBottomRight:Show(); 
	
		MultiCastActionBarFrame:ClearAllPoints();
		MultiCastActionBarFrame:SetPoint("BOTTOMLEFT", "MultiBarBottomRightButton1", "TOPLEFT", 7, 5);
		ShapeshiftBarFrame:ClearAllPoints();
		ShapeshiftBarFrame:SetPoint("BOTTOMLEFT", "MultiBarBottomRightButton1", "TOPLEFT", 7, 5);
		PetActionBarFrame:ClearAllPoints();
		PetActionBarFrame:SetPoint("BOTTOMLEFT", "MultiBarBottomRightButton1", "TOPLEFT", 7, 5);
	
			
	
end
	

	


function OnEvent()

	if (event=="PLAYER_ENTERING_WORLD") or (event=="VARIABLES_LOADED") then
		
	DoYourThing()
		
	end
		
end

function Update()

	DoYourThing()

end
Anyway I could make it better? I'm just looking for any tips really so I won't feel hurt if no one replies. Thank you so very much again

Cheers!
__________________




  Reply With Quote
09-16-09, 12:36 PM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
1. use self instead of this
2. make your functions local instead of polluting the global namespace with nondescript/generic function names - they will get overwritten (unless you're calling them from an xml file but they're located in a lua file - then they'll need to be global - but at least make them less generic and specific to your addon)
3. semicolons ( are unnecessary in lua
4. are you passing the event arg to your OnEvent function? Then you need to tell the function how to find the event variable (ie, OnEvent(self,event))
5. you actually don't even need to pass those arguments and check for the event, though, because you're not doing different things based on event. Just call your code in OnEvent straight out
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-17-09, 02:55 PM   #7
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Originally Posted by Laurent View Post
Anyway I could make it better?
If you want to make it harder for other addons to come in later an change what you've done and make it easier to change which frames you hide/reposition then you could do something like:

Code:
local function DoNothing() end

local hide = {
	'AchievementMicroButton',
	'ActionBarDownButton',
	'ActionBarUpButton',
	'CharacterBag0Slot',
	'CharacterBag1Slot',
	'CharacterBag2Slot',
	'CharacterBag3Slot',
	'ExhaustionLevelFillBar',
	'ExhaustionTick',
	'HelpMicroButton',
	'KeyRingButton',
	'LFGMicroButton',
	'MainMenuBarBackpackButton',
	'MainMenuBarLeftEndCap',
	'MainMenuBarMaxLevelBar',
	'MainMenuBarPageNumber',
	'MainMenuBarRightEndCap',
	'MainMenuBarTexture0',
	'MainMenuBarTexture1',
	'MainMenuBarTexture2',
	'MainMenuBarTexture3',
	'MainMenuExpBar',
	'PVPMicroButton',
	'ReputationWatchBar',
	'ShapeshiftBarLeft',
	'ShapeshiftBarMiddle',
	'ShapeshiftBarRight',
	'SlidingActionBarTexture0',
	'SlidingActionBarTextur1'
}

local reposition = {
	CharacterMicroButton	= { 'BOTTOM', TalentMicroButton, 'TOP', 0, -20 },
	MainMenuBar		= { 'BOTTOMLEFT', UIParent, 'BOTTOMLEFT', 0, 0 },
	MainMenuMicroButton	= { 'LEFT', QuestLogMicroButton, 'RIGHT', 3, 0 },
	MultiBarBottomLeft	= { 'BOTTOMLEFT', ActionButton1, 'TOPLEFT', 0, 5 },
	MultiBarBottomRight	= { 'BOTTOMLEFT', MultiBarBottomLeftButton1, 'TOPLEFT', 0, 5 },
	MultiCastActionBarFrame	= { 'BOTTOMLEFT', MultiBarBottomRightButton1, 'TOPLEFT', 7, 5 },
	PetActionBarFrame	= { 'BOTTOMLEFT', MultiBarBottomRightButton1, 'TOPLEFT', 7, 5 },
	QuestLogMicroButton	= { 'BOTTOMLEFT', ActionButton12, 'BOTTOMRIGHT', 3, 0 },
	ShapeshiftBarFrame	= { 'BOTTOMLEFT', MultiBarBottomRightButton1, 'TOPLEFT', 7, 5 },
	SocialsMicroButton	= { 'BOTTOM', MainMenuMicroButton, 'TOP', 0, -20 },
	SpellbookMicroButton	= { 'BOTTOM', SocialsMicroButton, 'TOP', 0, -20 },
	TalentMicroButton	= { 'BOTTOM', QuestLogMicroButton, 'TOP', 0, -20 }
}

local _G, frame = _G
for _, name in ipairs(hide) do
	frame = _G[name]
	if frame then
		frame:Hide()
		frame.Hide, frame.Show = DoNothing, DoNothing
	end
end

for name in pairs(reposition) do
	if _G[name] then
		_G[name]:ClearAllPoints()
	end
end

local unpack = unpack
for name, position in pairs(reposition) do
	frame = _G[name]
	if frame then
		frame:SetPoint(unpack(position))
		frame.ClearAllPoints, frame.SetAllPoints, frame.SetPoint = DoNothing, DoNothing, DoNothing
	end
end
  Reply With Quote
09-30-09, 08:04 AM   #8
Laurent
A Deviate Faerie Dragon
 
Laurent's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 12
OMG Thank you so much, I have no idea what half of that does but it works great. Kudos
__________________




  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Dependency Conflict

Thread Tools
Display Modes

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