View Single Post
03-01-13, 04:55 PM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I didn't look at your code, but I'd use the PLAYER_LOGIN event -- so that all non-LoD addons are loaded by the time it fires and, assuming they're using AceAddon's OnInitialize, have loaded and set up their profiles -- in conjunction with a saved variable for your addon; in this (fairly loose) example I've used the saved variable name MUI_INSTALLED.

Code:
local addons = {
	-- Global names of addon objects go here:
	"ShadowUF",
	"OtherAddon",
	"AnotherAddon",
}

local setupMode = "setup"

frame:SetScript("OnEvent", function(self, event, ...)
	if event == "PLAYER_LOGIN" then
		if MUI_INSTALLED then
			setupMode = nil
			-- Nothing to do. Turn everything off.
			return
		end

		for _, addon in pairs(addons) do
			if _G[addon].db:GetCurrentProfile() == "MayronUI" then
				setupMode = "bonus"
				break
			end
		end
		
		if setupMode == "setup" then
			-- Show initial setup window
		elseif setupMode == "bonus" then
			-- Show bonus setup window
		end
	end
end)

SetupExitButton:SetScript("OnClick", function(self)
	-- Do all the setup stuff
	ReloadUI()
end)

BonusExitButton:SetScript("OnClick", function(self)
	local reload
	if EnableChat:IsChecked() then -- asumes this is a CheckButton, not just a Button
		-- Setup bottom left chat box
		reload = true
	end
	if DisableClassColors:IsChecked() then
		-- Turn off class colors
		reload = true
	end
	if ClassicMode:IsChecked() then
		-- Setup classic mode
		reload = true
	end
	MUI_INSTALLED = true
	if reload then
		ReloadUI()
	else
		-- Nothing left to do. Turn everything off.
		self:Hide()
	end
end)
__________________
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