View Single Post
12-02-15, 08:04 AM   #4
jostor
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Nov 2011
Posts: 10
I'll provide some more context:

Code:
local config = CreateFrame("Frame")
This is how the config frame is created, this happens in the code outside of any function (in other words called as soon as the file starts executing)

The following then runs on PLAYER_LOGIN: (edited down slightly, just removing some code which is completely duplicate aside from some variable names and coordinates)
Code:
	config.title = config:CreateFontString("AIconfigTitleFont", "ARTWORK", "GameFontNormal")
	config.title:SetFont(GameFontNormal:GetFont(), 16, "OUTLINE")
	config.title:SetPoint("TOPLEFT", config, 10, -10)
	config.title:SetText(config.name)

	config.enablebox = CreateFrame("CheckButton", "AIenableButton", config, "InterfaceOptionsCheckButtonTemplate")
	config.enablebox:SetPoint("TOPLEFT", config, 10, -28)
	config.enablebox:SetChecked(options.enabled)
	config.enablebox:SetHitRectInsets(0, -200, 0, 0)
	config.enableboxtitle = config:CreateFontString("AIconfigEnableboxFont", "ARTWORK", "GameFontNormal")
	config.enableboxtitle:SetFont(GameFontNormal:GetFont(), 12, "OUTLINE")
	config.enableboxtitle:SetPoint("LEFT", config.enablebox, 30, 0)
	config.enableboxtitle:SetText("|cffffffff" .. L.enable_addon .. "|r")


	config.raidbox = CreateFrame("CheckButton", "AIraidButton", config, "InterfaceOptionsCheckButtonTemplate")
	config.raidbox:SetPoint("TOPLEFT", config, 10, -68)
	config.raidbox:SetChecked(options.inRaid)
	config.raidbox:SetHitRectInsets(0, -200, 0, 0)
	config.raidboxtitle = config:CreateFontString("AIconfigraidboxFont", "ARTWORK", "GameFontNormal")
	config.raidboxtitle:SetFont(GameFontNormal:GetFont(), 12, "OUTLINE")
	config.raidboxtitle:SetPoint("LEFT", config.raidbox, 30, 0)
	config.raidboxtitle:SetText("|cffffffff" .. L.active_raid .. "|r")


	config.channeltitle = config:CreateFontString("AIconfigchanneltitleFont", "ARTWORK", "GameFontNormal")
	config.channeltitle:SetFont(GameFontNormal:GetFont(), 12, "OUTLINE")
	config.channeltitle:SetPoint("TOPLEFT", config, 10, -233)
	config.channeltitle:SetText("|cffffffff" .. L.channel .. "|r")

	config.channeldropdown = CreateFrame("Button", "AIchannelDropdown", config, "UIDropDownMenuTemplate")
	config.channeldropdown:SetPoint("TOPLEFT", config, 10, -253)

	UIDropDownMenu_Initialize(config.channeldropdown, function(self, level)   
		local info = UIDropDownMenu_CreateInfo()
		local channelOptions = {
			L.channel_say,
			L.channel_raid,
			L.channel_party,
			L.channel_instance,
			L.channel_yell,
			L.channel_self,
			L.channel_emote,
			L.channel_whisper,
			L.channel_custom
		}
		for k,v in pairs(channelOptions) do
			info = UIDropDownMenu_CreateInfo()
			info.text = v
			info.value = v
			info.func = function(self) UIDropDownMenu_SetSelectedID(config.channeldropdown, self:GetID()) if self:GetID() < 8 then config.channelextrabox:Hide() else config.channelextrabox:Show() end end
			UIDropDownMenu_AddButton(info, level)
		end 
	end)
	UIDropDownMenu_SetSelectedID(config.channeldropdown, selectIdFromChannelName(options.channel))

	config.channelextrabox = CreateFrame("EditBox", "AIextrachannelbox", config.channeldropdown, "InputBoxTemplate")
	config.channelextrabox:SetPoint("RIGHT", 250, 2)
	config.channelextrabox:SetSize(130, 25)
	config.channelextrabox:SetAutoFocus(false)
	config.channelextrabox:SetScript("OnEnterPressed", function(self) self:ClearFocus() end)
	if UIDropDownMenu_GetSelectedID(config.channeldropdown) < 7 then
		config.channelextrabox:Hide()
	end
	config.channelextrabox:SetText(options.channelExtra)
	config.channelextrabox:SetCursorPosition(0)


	config.smartbox = CreateFrame("CheckButton", "AIsmartChannelButton", config, "InterfaceOptionsCheckButtonTemplate")
	config.smartbox:SetPoint("TOPLEFT", config, 10, -283)
	config.smartbox:SetChecked(options.smartChannel)
	config.smartbox:SetHitRectInsets(0, -200, 0, 0)

	config.smartbox:SetScript("OnEnter", function(self)   
		GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT", 0, 0)
		GameTooltip:SetText(L.smart_channel)
		GameTooltip:AddLine(L.smart_details, 1, 1, 1)
		
		GameTooltip:Show() 
	end)

	config.smartbox:SetScript("OnLeave", function(self) GameTooltip:Hide() end)


	config.smartboxtitle = config:CreateFontString("AIconfigsmartboxFont", "ARTWORK", "GameFontNormal")
	config.smartboxtitle:SetFont(GameFontNormal:GetFont(), 12, "OUTLINE")
	config.smartboxtitle:SetPoint("LEFT", config.smartbox, 30, 0)
	config.smartboxtitle:SetText("|cffffffff" .. L.smart_channel .. "|r")
Config itself is added to Interface options with
Code:
InterfaceOptions_AddCategory(config)
This code is causing SetPoint() to be tainted which later causes problem for this user with the built-in raidframes as those also use the SetPoint() function.

All the code I posted runs when the player logs in, so it should not be in combat, and even if it is, doing this should still be okay in combat, as I am not modifying any frames depending on something happening in combat?
  Reply With Quote