Quantcast

mmm getting there

Xruptor [10-01-18 - 15:25]
mmm getting there
Filename
XanChat.lua
config.lua
locale/enUS.lua
diff --git a/XanChat.lua b/XanChat.lua
index 2c9b649..d3696c5 100644
--- a/XanChat.lua
+++ b/XanChat.lua
@@ -561,6 +561,9 @@ function eFrame:PLAYER_LOGIN()

 		if f then

+		XANCHAT_Frame = XANCHAT_Frame or {}
+		XANCHAT_Frame[i] = f
+
 			--restore saved layout
 			RestoreLayout(f)

@@ -650,16 +653,13 @@ function eFrame:PLAYER_LOGIN()
 			end
 			--hide the scroll bars
 			if XCHT_DB.hideScroll then
-				_G[n.."ButtonFrameUpButton"]:Hide()
-				_G[n.."ButtonFrameUpButton"]:SetScript("OnShow", dummy)
-				_G[n.."ButtonFrameDownButton"]:Hide()
-				_G[n.."ButtonFrameDownButton"]:SetScript("OnShow", dummy)
-				_G[n.."ButtonFrame"]:Hide()
-				_G[n.."ButtonFrame"]:SetScript("OnShow", dummy)
-				if _G[n.."ButtonFrameMinimizeButton"] then
-					--this button doesn't always appear for all chat frames
-					_G[n.."ButtonFrameMinimizeButton"]:Hide()
-					_G[n.."ButtonFrameMinimizeButton"]:SetScript("OnShow", dummy)
+				if f.buttonFrame then
+					f.buttonFrame:Hide()
+					f.buttonFrame:SetScript("OnShow", dummy)
+				end
+				if f.ScrollToBottomButton then
+					f.ScrollToBottomButton:Hide()
+					f.ScrollToBottomButton:SetScript("OnShow", dummy)
 				end
 			end

@@ -735,78 +735,25 @@ function eFrame:PLAYER_LOGIN()

 		if a and XCHT_DB then
 			if c and c:lower() == L.SlashSocial then
-				if XCHT_DB.hideSocial then
-					XCHT_DB.hideSocial = false
-					DEFAULT_CHAT_FRAME:AddMessage(L.SlashSocialOn)
-				else
-					XCHT_DB.hideSocial = true
-					DEFAULT_CHAT_FRAME:AddMessage(L.SlashSocialOff)
-				end
-				StaticPopup_Show("XANCHAT_APPLYCHANGES")
+				addon.aboutPanel.btnSocial.func()
 				return true
 			elseif c and c:lower() == L.SlashScroll then
-				if XCHT_DB.hideScroll then
-					XCHT_DB.hideScroll = false
-					DEFAULT_CHAT_FRAME:AddMessage(L.SlashScrollOn)
-				else
-					XCHT_DB.hideScroll = true
-					DEFAULT_CHAT_FRAME:AddMessage(L.SlashScrollOff)
-				end
-				StaticPopup_Show("XANCHAT_APPLYCHANGES")
+				addon.aboutPanel.btnScroll.func()
 				return true
 			elseif c and c:lower() == L.SlashShortNames then
-				if XCHT_DB.shortNames then
-					XCHT_DB.shortNames = false
-					DEFAULT_CHAT_FRAME:AddMessage(L.SlashShortNamesOff)
-				else
-					XCHT_DB.shortNames = true
-					DEFAULT_CHAT_FRAME:AddMessage(L.SlashShortNamesOn)
-				end
-				StaticPopup_Show("XANCHAT_APPLYCHANGES")
+				addon.aboutPanel.btnShortNames.func()
 				return true
 			elseif c and c:lower() == L.SlashEditBox then
-				if XCHT_DB.editBoxTop then
-					XCHT_DB.editBoxTop = false
-					setEditBox()
-					DEFAULT_CHAT_FRAME:AddMessage(L.SlashEditBoxBottom)
-				else
-					XCHT_DB.editBoxTop = true
-					setEditBox(true)
-					DEFAULT_CHAT_FRAME:AddMessage(L.SlashEditBoxTop)
-				end
+				addon.aboutPanel.btnEditBox.func()
 				return true
 			elseif c and c:lower() == L.SlashTabs then
-				if XCHT_DB.hideTabs then
-					XCHT_DB.hideTabs = false
-					DEFAULT_CHAT_FRAME:AddMessage(L.SlashTabsOn)
-				else
-					XCHT_DB.hideTabs = true
-					DEFAULT_CHAT_FRAME:AddMessage(L.SlashTabsOff)
-				end
-				StaticPopup_Show("XANCHAT_APPLYCHANGES")
+				addon.aboutPanel.btnTabs.func()
 				return true
 			elseif c and c:lower() == L.SlashShadow then
-				if XCHT_DB.addFontShadow then
-					XCHT_DB.addFontShadow = false
-					DEFAULT_CHAT_FRAME:AddMessage(L.SlashShadowOff)
-				else
-					XCHT_DB.addFontShadow = true
-					DEFAULT_CHAT_FRAME:AddMessage(L.SlashShadowOn)
-				end
-				StaticPopup_Show("XANCHAT_APPLYCHANGES")
+				addon.aboutPanel.btnShadow.func()
 				return true
 			elseif c and c:lower() == L.SlashVoice then
-				if XCHT_DB.hideVoice then
-					XCHT_DB.hideVoice = false
-					DEFAULT_CHAT_FRAME:AddMessage(L.SlashVoiceOn)
-				else
-					XCHT_DB.hideVoice = true
-					DEFAULT_CHAT_FRAME:AddMessage(L.SlashVoiceOff)
-					ChatFrameToggleVoiceDeafenButton:Hide()
-					ChatFrameToggleVoiceMuteButton:Hide()
-					ChatFrameChannelButton:Hide()
-				end
-				StaticPopup_Show("XANCHAT_APPLYCHANGES")
+				addon.aboutPanel.btnVoice.func()
 				return true
 			end
 		end
diff --git a/config.lua b/config.lua
index ec16104..34485f0 100644
--- a/config.lua
+++ b/config.lua
@@ -1,14 +1,23 @@
 local ADDON_NAME, addon = ...
 if not _G[ADDON_NAME] then _G[ADDON_NAME] = addon end

+addon.configEvent = CreateFrame("frame", ADDON_NAME.."_config_eventFrame",UIParent)
+local configEvent = addon.configEvent
+configEvent:SetScript("OnEvent", function(self, event, ...) if self[event] then return self[event](self, event, ...) end end)
+
+local L = LibStub("AceLocale-3.0"):GetLocale("xanChat")
 local chkBoxIndex = 1

-function createCheckbutton(parentFrame, displayText)
+function createCheckbutton(parentFrame, displayText, dbObjectValue)
 	chkBoxIndex = chkBoxIndex + 1

 	local checkbutton = CreateFrame("CheckButton", ADDON_NAME.."_config_chkbtn_" .. chkBoxIndex, parentFrame, "ChatConfigCheckButtonTemplate")
 	getglobal(checkbutton:GetName() .. 'Text'):SetText(" "..displayText)
-
+
+	checkbutton:SetScript("OnShow", function()
+			checkbutton:SetChecked(dbObjectValue)
+	end)
+
 	return checkbutton
 end

@@ -77,19 +86,130 @@ local function LoadAboutFrame()
 	return about
 end

-addon.aboutPanel = LoadAboutFrame()
-
-myCheckButton = createCheckbutton(addon.aboutPanel, "A Checkbox")
-myCheckButton:SetScript("OnClick", function()
-		print('click')
-end)
-addConfigEntry(myCheckButton)
-
-myCheckButton2 = createCheckbutton(addon.aboutPanel, "A Checkbox")
-myCheckButton2:SetScript("OnClick", function()
-		print('click')
-end)
-addConfigEntry(myCheckButton2)
-
+function configEvent:PLAYER_LOGIN()
+
+	addon.aboutPanel = LoadAboutFrame()
+
+	addon.aboutPanel.btnSocial = createCheckbutton(addon.aboutPanel, L.SlashSocialInfo, XCHT_DB.hideSocial)
+	addon.aboutPanel.btnSocial.func = function()
+		local value = addon.aboutPanel.btnSocial:GetChecked()
+
+		if not value then
+			XCHT_DB.hideSocial = false
+			DEFAULT_CHAT_FRAME:AddMessage(L.SlashSocialOn)
+		else
+			XCHT_DB.hideSocial = true
+			DEFAULT_CHAT_FRAME:AddMessage(L.SlashSocialOff)
+		end
+
+		StaticPopup_Show("XANCHAT_APPLYCHANGES")
+	end
+	addon.aboutPanel.btnSocial:SetScript("OnClick", addon.aboutPanel.btnSocial.func)
+	addConfigEntry(addon.aboutPanel.btnSocial)
+
+	addon.aboutPanel.btnScroll = createCheckbutton(addon.aboutPanel, L.SlashScrollInfo, XCHT_DB.hideScroll)
+	addon.aboutPanel.btnScroll.func = function()
+		local value = addon.aboutPanel.btnScroll:GetChecked()
+
+		if not value then
+			XCHT_DB.hideScroll = false
+			DEFAULT_CHAT_FRAME:AddMessage(L.SlashScrollOn)
+		else
+			XCHT_DB.hideScroll = true
+			DEFAULT_CHAT_FRAME:AddMessage(L.SlashScrollOff)
+		end
+
+		StaticPopup_Show("XANCHAT_APPLYCHANGES")
+	end
+	addon.aboutPanel.btnScroll:SetScript("OnClick", addon.aboutPanel.btnScroll.func)
+	addConfigEntry(addon.aboutPanel.btnScroll)
+
+	addon.aboutPanel.btnShortNames = createCheckbutton(addon.aboutPanel, L.SlashShortNamesInfo, XCHT_DB.shortNames)
+	addon.aboutPanel.btnShortNames.func = function()
+		local value = addon.aboutPanel.btnShortNames:GetChecked()
+
+		if not value then
+			XCHT_DB.shortNames = false
+			DEFAULT_CHAT_FRAME:AddMessage(L.SlashShortNamesOn)
+		else
+			XCHT_DB.shortNames = true
+			DEFAULT_CHAT_FRAME:AddMessage(L.SlashShortNamesOff)
+		end
+
+		StaticPopup_Show("XANCHAT_APPLYCHANGES")
+	end
+	addon.aboutPanel.btnShortNames:SetScript("OnClick", addon.aboutPanel.btnShortNames.func)
+	addConfigEntry(addon.aboutPanel.btnShortNames)
+
+	addon.aboutPanel.btnEditBox = createCheckbutton(addon.aboutPanel, L.SlashEditBoxInfo, XCHT_DB.editBoxTop)
+	addon.aboutPanel.btnEditBox.func = function()
+		local value = addon.aboutPanel.btnEditBox:GetChecked()
+
+		if not value then
+			XCHT_DB.editBoxTop = false
+			DEFAULT_CHAT_FRAME:AddMessage(L.SlashEditBoxBottom)
+		else
+			XCHT_DB.editBoxTop = true
+			DEFAULT_CHAT_FRAME:AddMessage(L.SlashEditBoxTop)
+		end
+
+		StaticPopup_Show("XANCHAT_APPLYCHANGES")
+	end
+	addon.aboutPanel.btnEditBox:SetScript("OnClick", addon.aboutPanel.btnEditBox.func)
+	addConfigEntry(addon.aboutPanel.btnEditBox)
+
+	addon.aboutPanel.btnTabs = createCheckbutton(addon.aboutPanel, L.SlashTabsInfo, XCHT_DB.hideTabs)
+	addon.aboutPanel.btnTabs.func = function()
+		local value = addon.aboutPanel.btnTabs:GetChecked()
+
+		if not value then
+			XCHT_DB.hideTabs = false
+			DEFAULT_CHAT_FRAME:AddMessage(L.SlashTabsOn)
+		else
+			XCHT_DB.hideTabs = true
+			DEFAULT_CHAT_FRAME:AddMessage(L.SlashTabsOff)
+		end
+
+		StaticPopup_Show("XANCHAT_APPLYCHANGES")
+	end
+	addon.aboutPanel.btnTabs:SetScript("OnClick", addon.aboutPanel.btnTabs.func)
+	addConfigEntry(addon.aboutPanel.btnTabs)
+
+	addon.aboutPanel.btnShadow = createCheckbutton(addon.aboutPanel, L.SlashShadowInfo, XCHT_DB.addFontShadow)
+	addon.aboutPanel.btnShadow.func = function()
+		local value = addon.aboutPanel.btnShadow:GetChecked()
+
+		if not value then
+			XCHT_DB.addFontShadow = false
+			DEFAULT_CHAT_FRAME:AddMessage(L.SlashShadowOff)
+		else
+			XCHT_DB.addFontShadow = true
+			DEFAULT_CHAT_FRAME:AddMessage(L.SlashShadowOn)
+		end
+
+		StaticPopup_Show("XANCHAT_APPLYCHANGES")
+	end
+	addon.aboutPanel.btnShadow:SetScript("OnClick", addon.aboutPanel.btnShadow.func)
+	addConfigEntry(addon.aboutPanel.btnShadow)
+
+	addon.aboutPanel.btnVoice = createCheckbutton(addon.aboutPanel, L.SlashVoiceInfo, XCHT_DB.hideVoice)
+	addon.aboutPanel.btnVoice.func = function()
+		local value = addon.aboutPanel.btnVoice:GetChecked()
+
+		if not value then
+			XCHT_DB.hideVoice = false
+			DEFAULT_CHAT_FRAME:AddMessage(L.SlashVoiceOn)
+		else
+			XCHT_DB.hideVoice = true
+			DEFAULT_CHAT_FRAME:AddMessage(L.SlashVoiceOff)
+		end
+
+		StaticPopup_Show("XANCHAT_APPLYCHANGES")
+	end
+	addon.aboutPanel.btnVoice:SetScript("OnClick", addon.aboutPanel.btnVoice.func)
+	addConfigEntry(addon.aboutPanel.btnVoice)

+	configEvent:UnregisterEvent("PLAYER_LOGIN")
+end

+if IsLoggedIn() then configEvent:PLAYER_LOGIN() else configEvent:RegisterEvent("PLAYER_LOGIN") end
\ No newline at end of file
diff --git a/locale/enUS.lua b/locale/enUS.lua
index 13cc0df..09cc28d 100644
--- a/locale/enUS.lua
+++ b/locale/enUS.lua
@@ -13,7 +13,7 @@ L.WhoPlayer = "Who Player?"
 L.GuildInvite = "Guild Invite"
 L.CopyName = "Copy Name"
 L.URLCopy = "URL COPY"
-L.ApplyChanges = "xanChat: Would you like to apply the changes now?"
+L.ApplyChanges = "xanChat: UI must be reloaded to apply changes!"
 L.Yes = "Yes"
 L.No = "No"