Quantcast

Some strong voodoo to fix chat positioning. This fixes #345

Darthpred [10-09-16 - 13:30]
Some strong voodoo to fix chat positioning. This fixes #345
Filename
ElvUI_SLE/defaults/private.lua
ElvUI_SLE/locales/english.lua
ElvUI_SLE/locales/russian.lua
ElvUI_SLE/modules/chat/chat.lua
ElvUI_SLE/modules/datatexts.lua
ElvUI_SLE/options/chat/chat_c.lua
diff --git a/ElvUI_SLE/defaults/private.lua b/ElvUI_SLE/defaults/private.lua
index 7dd2c0f..55b7364 100644
--- a/ElvUI_SLE/defaults/private.lua
+++ b/ElvUI_SLE/defaults/private.lua
@@ -216,5 +216,8 @@ G["sle"] = {
 			["commands"] = false,
 			["devCommands"] = false,
 		},
+		["chat"] = {
+			["setupDelay"] = 1,
+		},
 	},
 }
\ No newline at end of file
diff --git a/ElvUI_SLE/locales/english.lua b/ElvUI_SLE/locales/english.lua
index dff706d..57b9e5b 100644
--- a/ElvUI_SLE/locales/english.lua
+++ b/ElvUI_SLE/locales/english.lua
@@ -300,6 +300,8 @@ L["Invite links"] = true
 L["Convets specified keywords to links that automatically invite message's author to group."] = true
 L["Link Color"] = true
 L["Invite Keywords"] = true
+L["Chat Setup Delay"] = true
+L["Manages the delay before S&L will execute hooks to ElvUI's chat positioning. Prevents some weird positioning issues."] = true

 --Databars
 L["Full value on Exp Bar"] = true
diff --git a/ElvUI_SLE/locales/russian.lua b/ElvUI_SLE/locales/russian.lua
index c1b0927..275ad7a 100644
--- a/ElvUI_SLE/locales/russian.lua
+++ b/ElvUI_SLE/locales/russian.lua
@@ -295,6 +295,8 @@ L["Invite links"] = "Ссылки для приглашения"
 L["Convets specified keywords to links that automatically invite message's author to group."] = "Превращает указаные слова в ссылки, клик по которым пригласит автора сообщения в группу."
 L["Link Color"] = "Цвет ссылки"
 L["Invite Keywords"] = "Ключевые слова для приглашения"
+L["Chat Setup Delay"] = "Задержка подключения ата"
+L["Manages the delay before S&L will execute hooks to ElvUI's chat positioning. Prevents some weird positioning issues."] = "задает задержку до выполнения хуков к функция позиционирования ElvUI. Предотвращает некоторые проблемы расположения окон чата."

 --Databars
 L["Full value on Exp Bar"] = "Полное значение опыта"
diff --git a/ElvUI_SLE/modules/chat/chat.lua b/ElvUI_SLE/modules/chat/chat.lua
index 7c09cfb..a2d88cf 100644
--- a/ElvUI_SLE/modules/chat/chat.lua
+++ b/ElvUI_SLE/modules/chat/chat.lua
@@ -305,7 +305,8 @@ function C:Initialize()

 	--Launching stuff so hooks can work
 	LO:ToggleChatPanels()
-	CH:SetupChat()
+	local setupDelay = E.global.sle.advanced.chat.setupDelay
+	E:Delay(setupDelay, function() CH:SetupChat() end) --This seems to actually fix some issues with detecting right panel chat frame
 	--Justify
 	for i = 1, NUM_CHAT_WINDOWS do
 		C:JustifyChat(i)
diff --git a/ElvUI_SLE/modules/datatexts.lua b/ElvUI_SLE/modules/datatexts.lua
index defc6f4..d0263d9 100644
--- a/ElvUI_SLE/modules/datatexts.lua
+++ b/ElvUI_SLE/modules/datatexts.lua
@@ -163,9 +163,17 @@ function DTP:ChatResize()
 	_G["LeftChatToggleButton"]:SetAlpha(DTP.db.leftchat.alpha)
 	_G["RightChatDataPanel"]:SetAlpha(DTP.db.rightchat.alpha)
 	_G["RightChatToggleButton"]:SetAlpha(DTP.db.rightchat.alpha)
-	if not DTP.db.chathandle then return end
-	_G["LeftChatDataPanel"]:Width(DTP.db.leftchat.width - E.Spacing*2)
-	_G["RightChatDataPanel"]:Width(DTP.db.rightchat.width  - E.Spacing*2)
+	--A lot of weird math to prevent chat frames from flying around the place
+	if DTP.db.chathandle and E.db.datatexts.leftChatPanel then
+		_G["LeftChatDataPanel"]:Width(DTP.db.leftchat.width - E.Spacing*2)
+	else
+		_G["LeftChatDataPanel"]:Width(E.db.chat.panelWidth - (2*(E.Border*3 - E.Spacing) + 16))
+	end
+	if DTP.db.chathandle and E.db.datatexts.rightChatPanel then
+		_G["RightChatDataPanel"]:Width(DTP.db.rightchat.width  - E.Spacing*2)
+	else
+		_G["RightChatDataPanel"]:Width(((E.db.chat.separateSizes and E.db.chat.panelWidthRight) or E.db.chat.panelWidth) - (2*(E.Border*3 - E.Spacing) + 16))
+	end
 end

 function DTP:CreateAndUpdatePanels()
diff --git a/ElvUI_SLE/options/chat/chat_c.lua b/ElvUI_SLE/options/chat/chat_c.lua
index 19f821e..8e50c5f 100644
--- a/ElvUI_SLE/options/chat/chat_c.lua
+++ b/ElvUI_SLE/options/chat/chat_c.lua
@@ -76,6 +76,16 @@ local function configTable()
 					["RIGHT"] = L["Right"],
 				}
 			},
+			setupDelay = {
+				order = 10,
+				type = "range",
+				name = L["Chat Setup Delay"],
+				desc = L["Manages the delay before S&L will execute hooks to ElvUI's chat positioning. Prevents some weird positioning issues."],
+				hidden = function() return not E.global.sle.advanced.general end,
+				min = 0.5, max = 10, step = .1,
+				get = function(info) return E.global.sle.advanced.chat[ info[#info] ] end,
+				set = function(info, value) E.global.sle.advanced.chat[ info[#info] ] = value; E:StaticPopup_Show("GLOBAL_RL") end,
+			},
 			textureAlpha = {
 				order = 20, type = "group",
 				name = L["Texture Alpha"],