View Single Post
11-02-10, 08:40 AM   #15
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by Duugu View Post
I must admit I don't overlook your code. (especially not the addon.RegisterEvent thingi ... where does it come from??)
But I know the addons code is loaded and exectuted before the saved vars are loaded - which means the DefaultMoveableFrames() stuff will be done and then GMoveableFrames will be loaded from the saved vars. Or?

What happens if you delete the addons saved vars file?
Does the new file then contain all the table entries from GMoveableFrames?
Nope it does not, if i delete the wtf the new entry contains only 8 of those entrys.

The way it should all work is... when you load the game the addon should check the saved vars for the GMoveableFrames entry, if it does not find it then it should load the big list of frames in the lua, if it does then it should load the list in the savedvars wtf instead. Then on log out save any frames added/removed.

Which leads me to another question... would it be better for me to have the add remove frame function enter table entrys or should i make that function put the entrys in the saved var file? once i figure out how to get things to go back and forth properly...

note - some of the way it should work i know is not right but when i did it the way i first thought i still had the only 8 entrys problem so i tried this way... and a few other ways.

here is the registerevent functions... its in the core.lua

Code:
--[[-----------------------------------------------------------------------------
Event handling - Use one frame to process multiple individual OnEvent needs
-------------------------------------------------------------------------------]]
do
	local frame, select, next, events = CreateFrame('Frame'), select, pairs({ })
	local register, unregister = frame.RegisterEvent, frame.UnregisterEvent
	frame:Hide()

	frame:SetScript('OnEvent', function(self, event, ...)
		for reference, func in next, events[event], nil do
			func(reference, event, ...)
		end
	end)

	function addon.RegisterEvent(reference, event, func)
		if not events[event] then
			events[event] = { }
			register(frame, event)
		end
		events[event][reference] = func
	end

	function addon.RegisterEvents(reference, func, ...)
		local event
		for index = 1, select('#', ...) do
			event = select(index, ...)
			if not events[event] then
				events[event] = { }
				register(frame, event)
			end
			events[event][reference] = func
		end
	end

	function addon.UnregisterEvent(reference, event)
		if events[event] then
			events[event][reference] = nil
			if not next(events[event]) then
				events[event] = nil
				unregister(frame, event)
			end
		end
	end

	function addon.UnregisterAllEvents(reference)
		for event, registry in next, events, nil do
			registry[reference] = nil
			if not next(registry) then
				events[event] = nil
				unregister(frame, event)
			end
		end
	end
end

--[[-----------------------------------------------------------------------------
SafeCall - Queue a method of addon to run once combat ends if needed
-------------------------------------------------------------------------------]]
do
	local combatLockdown, queue = InCombatLockdown(), { }

	addon.RegisterEvent("Core-SafeCall-EnterCombat", 'PLAYER_REGEN_DISABLED', function(self)
		combatLockdown = true
	end)

	addon.RegisterEvent("Core-SafeCall-LeaveCombat", 'PLAYER_REGEN_ENABLED', function(self)
		combatLockdown = nil
		for method, arg in pairs(queue) do
			addon[method](addon, arg)
			queue[method] = nil
		end
	end)

	function addon:SafeCall(method, arg)
		if combatLockdown then
			queue[method] = arg or false
		else
			addon[method](addon, arg)
		end
	end
end
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 11-02-10 at 08:47 AM.
  Reply With Quote