- Added support for embed on Chat Tabs.

This commit is contained in:
Tercio
2015-06-18 13:33:38 -03:00
parent a3eee58cb2
commit 7a3d822a8e
5 changed files with 329 additions and 9 deletions
+2 -2
View File
File diff suppressed because one or more lines are too long
+256
View File
@@ -17,6 +17,262 @@ function _detalhes:UpdateGears()
end
------------------------------------------------------------------------------------------------------------
--> chat hooks
_detalhes.chat_embed = _detalhes:CreateEventListener()
_detalhes.chat_embed.startup = true
_detalhes.chat_embed.hook_settabname = function (frame, name, doNotSave)
if (not doNotSave) then
if (_detalhes.chat_tab_embed.enabled and _detalhes.chat_tab_embed.tab_name ~= "") then
if (_detalhes.chat_tab_embed_onframe == frame) then
_detalhes.chat_tab_embed.tab_name = name
_detalhes:DelayOptionsRefresh (_detalhes:GetInstance(1))
end
end
end
end
_detalhes.chat_embed.hook_closetab = function (frame, fallback)
if (_detalhes.chat_tab_embed.enabled and _detalhes.chat_tab_embed.tab_name ~= "") then
if (_detalhes.chat_tab_embed_onframe == frame) then
_detalhes.chat_tab_embed.enabled = false
_detalhes.chat_tab_embed.tab_name = ""
_detalhes.chat_tab_embed_onframe = nil
_detalhes:DelayOptionsRefresh (_detalhes:GetInstance(1))
_detalhes.chat_embed:ReleaseEmbed()
end
end
end
hooksecurefunc ("FCF_SetWindowName", _detalhes.chat_embed.hook_settabname)
hooksecurefunc ("FCF_Close", _detalhes.chat_embed.hook_closetab)
function _detalhes.chat_embed:SetTabSettings (tab_name, is_enabled, is_single)
local current_enabled_state = _detalhes.chat_tab_embed.enabled
local current_name = _detalhes.chat_tab_embed.tab_name
tab_name = tab_name or _detalhes.chat_tab_embed.tab_name
if (is_enabled == nil) then
is_enabled = _detalhes.chat_tab_embed.enabled
end
if (is_single == nil) then
is_single = _detalhes.chat_tab_embed.single_window
end
_detalhes.chat_tab_embed.tab_name = tab_name or ""
_detalhes.chat_tab_embed.enabled = is_enabled
_detalhes.chat_tab_embed.single_window = is_single
if (current_name ~= tab_name) then
--> rename the tab on chat frame
local ChatFrame = _detalhes.chat_embed:GetTab (current_name)
if (ChatFrame) then
FCF_SetWindowName (ChatFrame, tab_name, false)
end
end
if (is_enabled) then
--> need to make the embed
_detalhes.chat_embed:DoEmbed()
else
--> need to release the frame
if (current_enabled_state) then
_detalhes.chat_embed:ReleaseEmbed()
end
end
end
function _detalhes.chat_embed:CheckChatEmbed (is_startup)
if (_detalhes.chat_tab_embed.enabled) then
_detalhes.chat_embed:DoEmbed (is_startup)
end
end
--dom
-- /run _detalhes.chat_embed:SetTabSettings ("Dano", true, false)
-- /run _detalhes.chat_embed:SetTabSettings (nil, false, false)
-- /dump _detalhes.chat_tab_embed.tab_name
function _detalhes.chat_embed:DelayedChatEmbed (is_startup)
_detalhes.chat_embed.startup = nil
_detalhes.chat_embed:DoEmbed()
end
function _detalhes.chat_embed:DoEmbed (is_startup)
if (_detalhes.chat_embed.startup and not is_startup) then
if (_detalhes.AddOnStartTime + 5 < GetTime()) then
_detalhes.chat_embed.startup = nil
else
return
end
end
if (is_startup) then
return _detalhes.chat_embed:ScheduleTimer ("DelayedChatEmbed", 5)
end
local tabname = _detalhes.chat_tab_embed.tab_name
if (_detalhes.chat_tab_embed.enabled and tabname ~= "") then
local ChatFrame, ChatFrameTab, ChatFrameBackground = _detalhes.chat_embed:GetTab (tabname)
if (not ChatFrame) then
FCF_OpenNewWindow (tabname)
ChatFrame, ChatFrameTab, ChatFrameBackground = _detalhes.chat_embed:GetTab (tabname)
end
if (ChatFrame) then
for index, t in pairs (ChatFrame.messageTypeList) do
ChatFrame_RemoveMessageGroup (ChatFrame, t)
ChatFrame.messageTypeList [index] = nil
end
_detalhes.chat_tab_embed_onframe = ChatFrame
if (_detalhes.chat_tab_embed.single_window) then
--> only one window
local window1 = _detalhes:GetInstance (1)
window1:UngroupInstance()
window1.baseframe:ClearAllPoints()
window1.baseframe:SetParent (ChatFrame)
window1.rowframe:SetParent (window1.baseframe)
window1.rowframe:ClearAllPoints()
window1.rowframe:SetAllPoints()
local y_up = window1.toolbar_side == 1 and -20 or 0
local y_down = (window1.show_statusbar and 14 or 0) + (window1.toolbar_side == 2 and 20 or 0)
window1.baseframe:SetPoint ("topleft", ChatFrameBackground, "topleft", 0, y_up)
window1.baseframe:SetPoint ("bottomright", ChatFrameBackground, "bottomright", 0, y_down)
window1:LockInstance (true)
window1:SaveMainWindowPosition()
local window2 = _detalhes:GetInstance (2)
if (window2) then
if (window2.baseframe:GetParent() == ChatFrame) then
--> need to detach
_detalhes.chat_embed:ReleaseEmbed (true)
end
end
else
--> window #1 and #2
local window1 = _detalhes:GetInstance (1)
local window2 = _detalhes:GetInstance (2)
if (not window2) then
window2 = _detalhes:CriarInstancia()
end
window1:UngroupInstance()
window2:UngroupInstance()
window1.baseframe:ClearAllPoints()
window2.baseframe:ClearAllPoints()
window1.baseframe:SetParent (ChatFrame)
window2.baseframe:SetParent (ChatFrame)
window1.rowframe:SetParent (window1.baseframe)
window2.rowframe:SetParent (window2.baseframe)
window1:LockInstance (true)
window2:LockInstance (true)
local statusbar_enabled1 = window1.show_statusbar
local statusbar_enabled2 = window2.show_statusbar
table.wipe (window1.snap); table.wipe (window2.snap)
window1.snap [3] = 2; window2.snap [1] = 1;
window1.horizontalSnap = true; window2.horizontalSnap = true
local y_up = window1.toolbar_side == 1 and -20 or 0
local y_down = (window1.show_statusbar and 14 or 0) + (window1.toolbar_side == 2 and 20 or 0)
local width = ChatFrameBackground:GetWidth() / 2
local height = ChatFrameBackground:GetHeight() - y_down + y_up
window1.baseframe:SetSize (width, height)
window2.baseframe:SetSize (width, height)
window1.baseframe:SetPoint ("topleft", ChatFrameBackground, "topleft", 0, y_up)
window2.baseframe:SetPoint ("topright", ChatFrameBackground, "topright", 0, y_up)
window1:SaveMainWindowPosition()
window2:SaveMainWindowPosition()
-- /dump ChatFrame3Background:GetSize()
--[[
_detalhes.move_janela_func (window1.baseframe, true, window1)
_detalhes.move_janela_func (window1.baseframe, false, window1)
_detalhes.move_janela_func (window2.baseframe, true, window2)
_detalhes.move_janela_func (window2.baseframe, false, window2)
--]]
end
end
end
end
function _detalhes.chat_embed:ReleaseEmbed (second_window)
--> release
local window1 = _detalhes:GetInstance (1)
local window2 = _detalhes:GetInstance (2)
if (second_window) then
window2.baseframe:ClearAllPoints()
window2.baseframe:SetParent (UIParent)
window2.rowframe:SetParent (UIParent)
window2.baseframe:SetPoint ("center", UIParent, "center", 200, 0)
window2.rowframe:SetPoint ("center", UIParent, "center", 200, 0)
window2:LockInstance (false)
return
end
window1.baseframe:ClearAllPoints()
window1.baseframe:SetParent (UIParent)
window1.rowframe:SetParent (UIParent)
window1.baseframe:SetPoint ("center", UIParent, "center")
window1.rowframe:SetPoint ("center", UIParent, "center")
window1:LockInstance (false)
if (not _detalhes.chat_tab_embed.single_window and window2) then
window2.baseframe:ClearAllPoints()
window2.baseframe:SetParent (UIParent)
window2.rowframe:SetParent (UIParent)
window2.baseframe:SetPoint ("center", UIParent, "center", 200, 0)
window2.rowframe:SetPoint ("center", UIParent, "center", 200, 0)
window2:LockInstance (false)
end
end
function _detalhes.chat_embed:GetTab (tabname)
tabname = tabname or _detalhes.chat_tab_embed.tab_name
for i = 1, 20 do
local tabtext = _G ["ChatFrame" .. i .. "TabText"]
if (tabtext) then
if (tabtext:GetText() == tabname) then
return _G ["ChatFrame" .. i], _G ["ChatFrame" .. i .. "Tab"], _G ["ChatFrame" .. i .. "Background"], i
end
end
end
end
--[[
--create a tab on chat
--FCF_OpenNewWindow(name)
--rename it? perhaps need to hook
--FCF_SetWindowName(chatFrame, name, true) --FCF_SetWindowName(3, "DDD", true)
--/run local chatFrame = _G["ChatFrame3"]; FCF_SetWindowName(chatFrame, "DDD", true)
--FCF_SetWindowName(frame, name, doNotSave)
--API SetChatWindowName(frame:GetID(), name); -- set when doNotSave is false
-- need to store the chat frame reference
-- hook set window name and check if the rename was on our window
--FCF_Close
-- ^ when the window is closed
--]]
------------------------------------------------------------------------------------------------------------
function _detalhes:SetDeathLogLimit (limit)
+6
View File
@@ -946,6 +946,12 @@ local default_profile = {
profile_save_pos = true,
options_group_edit = true,
chat_tab_embed = {
enabled = false,
tab_name = "",
single_window = false,
},
--> tooltip
tooltip = {
fontface = "Friz Quadrata TT",
+60 -7
View File
@@ -1278,7 +1278,7 @@ function window:CreateFrame20()
-- text size
g:NewLabel (frame20, _, "$parentTooltipTextSizeLabel", "TooltipTextSizeLabel", Loc ["STRING_OPTIONS_TOOLTIPS_FONTSIZE"], "GameFontHighlightLeft")
local s = g:NewSlider (frame20, _, "$parentTooltipTextSizeSlider", "TooltipTextSizeSlider", SLIDER_WIDTH, SLIDER_HEIGHT, 8, 32, 1, tonumber (_detalhes.tooltip.fontsize))
local s = g:NewSlider (frame20, _, "$parentTooltipTextSizeSlider", "TooltipTextSizeSlider", SLIDER_WIDTH, SLIDER_HEIGHT, 5, 32, 1, tonumber (_detalhes.tooltip.fontsize))
config_slider (s)
frame20.TooltipTextSizeSlider:SetPoint ("left", frame20.TooltipTextSizeLabel, "right", 2)
@@ -2274,7 +2274,7 @@ function window:CreateFrame18()
--> menu text size
g:NewLabel (frame18, _, "$parentMenuTextSizeLabel", "MenuTextSizeLabel", Loc ["STRING_OPTIONS_MENU_FONT_SIZE"], "GameFontHighlightLeft")
local s = g:NewSlider (frame18, _, "$parentMenuTextSizeSlider", "MenuTextSizeSlider", SLIDER_WIDTH, SLIDER_HEIGHT, 8, 32, 1, _detalhes.font_sizes.menus)
local s = g:NewSlider (frame18, _, "$parentMenuTextSizeSlider", "MenuTextSizeSlider", SLIDER_WIDTH, SLIDER_HEIGHT, 5, 32, 1, _detalhes.font_sizes.menus)
config_slider (s)
frame18.MenuTextSizeSlider:SetPoint ("left", frame18.MenuTextSizeLabel, "right", 2)
@@ -3501,7 +3501,7 @@ function window:CreateFrame14()
--size
g:NewLabel (frame14, _, "$parentAttributeTextSizeLabel", "attributeTextSizeLabel", Loc ["STRING_OPTIONS_MENU_ATTRIBUTE_TEXTSIZE"], "GameFontHighlightLeft")
local s = g:NewSlider (frame14, _, "$parentAttributeTextSizeSlider", "attributeTextSizeSlider", SLIDER_WIDTH, SLIDER_HEIGHT, 8, 32, 1, tonumber ( instance.attribute_text.text_size))
local s = g:NewSlider (frame14, _, "$parentAttributeTextSizeSlider", "attributeTextSizeSlider", SLIDER_WIDTH, SLIDER_HEIGHT, 5, 32, 1, tonumber ( instance.attribute_text.text_size))
config_slider (s)
frame14.attributeTextSizeSlider:SetPoint ("left", frame14.attributeTextSizeLabel, "right", 2)
@@ -5292,11 +5292,50 @@ function window:CreateFrame3()
g:NewLabel (frame3, _, "$parentPDWSkinLabel", "PDWSkinLabel", Loc ["STRING_OPTIONS_INSTANCE_SKIN"], "GameFontHighlightLeft")
window:CreateLineBackground2 (frame3, "PDWSkinDropdown", "PDWSkinLabel", Loc ["STRING_OPTIONS_PDW_SKIN_DESC"])
frame3.PDWSkinDropdown:SetPoint ("left", frame3.PDWSkinLabel, "right", 2)
--> chat tab embed
g:NewLabel (frame3, _, "$parentChatTabEmbedAnchor", "ChatTabEmbedAnchor", Loc ["STRING_OPTIONS_TABEMB_ANCHOR"], "GameFontNormal")
--> enabled
g:NewSwitch (frame3, _, "$parentChatTabEmbedEnabledSlider", "ChatTabEmbedEnabledSlider", 60, 20, _, _, _detalhes.chat_tab_embed.enabled)
g:NewLabel (frame3, _, "$parentChatTabEmbedEnabledLabel", "ChatTabEmbedEnabledLabel", Loc ["STRING_ENABLED"], "GameFontHighlightLeft")
frame3.ChatTabEmbedEnabledSlider:SetPoint ("left", frame3.ChatTabEmbedEnabledLabel, "right", 2)
frame3.ChatTabEmbedEnabledSlider.OnSwitch = function (self, instance, value)
_detalhes.chat_embed:SetTabSettings (_, value)
_detalhes:SendOptionsModifiedEvent (DetailsOptionsWindow.instance)
end
window:CreateLineBackground2 (frame3, "ChatTabEmbedEnabledSlider", "ChatTabEmbedEnabledLabel", Loc ["STRING_OPTIONS_TABEMB_ENABLED_DESC"])
--> window name
local tab_on_press_enter = function (_, _, text)
_detalhes.chat_embed:SetTabSettings (text)
end
local tabname = g:NewTextEntry (frame3, _, "$parentChatTabEmbedNameEntry", "ChatTabEmbedNameEntry", SLIDER_WIDTH, SLIDER_HEIGHT, tab_on_press_enter)
g:NewLabel (frame3, _, "$parentChatTabEmbedNameLabel", "ChatTabEmbedNameLabel", Loc ["STRING_OPTIONS_TABEMB_TABNAME"], "GameFontHighlightLeft")
tabname:SetPoint ("left", frame3.ChatTabEmbedNameLabel, "right", 2)
window:CreateLineBackground2 (frame3, "ChatTabEmbedNameEntry", "ChatTabEmbedNameLabel", Loc ["STRING_OPTIONS_TABEMB_TABNAME_DESC"])
tabname.text = _detalhes.chat_tab_embed.tab_name
--> one or two windows
g:NewSwitch (frame3, _, "$parentChatTabEmbed2WindowsSlider", "ChatTabEmbed2WindowsSlider", 60, 20, _, _, _detalhes.chat_tab_embed.single_window)
g:NewLabel (frame3, _, "$parentChatTabEmbed2WindowsLabel", "ChatTabEmbed2WindowsLabel", Loc ["STRING_OPTIONS_TABEMB_SINGLE"], "GameFontHighlightLeft")
frame3.ChatTabEmbed2WindowsSlider:SetPoint ("left", frame3.ChatTabEmbed2WindowsLabel, "right", 2)
frame3.ChatTabEmbed2WindowsSlider.OnSwitch = function (self, instance, value)
_detalhes.chat_embed:SetTabSettings (_, _, value)
_detalhes:SendOptionsModifiedEvent (DetailsOptionsWindow.instance)
end
window:CreateLineBackground2 (frame3, "ChatTabEmbed2WindowsSlider", "ChatTabEmbed2WindowsLabel", Loc ["STRING_OPTIONS_TABEMB_SINGLE_DESC"])
--> extra Options
--> extra Options -~-extra
g:NewLabel (frame3, _, "$parentSkinExtraOptionsAnchor", "SkinExtraOptionsAnchor", Loc ["STRING_OPTIONS_SKIN_EXTRA_OPTIONS_ANCHOR"], "GameFontNormal")
--frame3.SkinExtraOptionsAnchor:Hide()
frame3.SkinExtraOptionsAnchor:SetPoint (window.right_start_at, -90)
--frame3.SkinExtraOptionsAnchor:SetPoint (window.right_start_at, -90)
frame3.ExtraOptions = {}
--> Anchors
@@ -5328,10 +5367,19 @@ function window:CreateFrame3()
{"PDWAnchor", 12, true},
{"PDWSkinLabel", 13},
}
local right_side = {
{"ChatTabEmbedAnchor", 1, true},
{"ChatTabEmbedEnabledLabel", 2},
{"ChatTabEmbedNameLabel", 3},
{"ChatTabEmbed2WindowsLabel", 4},
{"SkinExtraOptionsAnchor", 5, true},
}
window:arrange_menu (frame3, left_side, x, -90)
window:arrange_menu (frame3, right_side, window.right_start_at, -90)
end
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -5988,7 +6036,7 @@ function window:CreateFrame5()
window:CreateLineBackground2 (frame5, "fixedTextColor", "fixedTextColorLabel", Loc ["STRING_OPTIONS_TEXT_FIXEDCOLOR_DESC"])
--> text size
local s = g:NewSlider (frame5, _, "$parentSliderFontSize", "fonsizeSlider", SLIDER_WIDTH, SLIDER_HEIGHT, 8, 32, 1, tonumber (instance.row_info.font_size))
local s = g:NewSlider (frame5, _, "$parentSliderFontSize", "fonsizeSlider", SLIDER_WIDTH, SLIDER_HEIGHT, 5, 32, 1, tonumber (instance.row_info.font_size))
config_slider (s)
g:NewLabel (frame5, _, "$parentFontSizeLabel", "fonsizeLabel", Loc ["STRING_OPTIONS_TEXT_SIZE"], "GameFontHighlightLeft")
@@ -10141,6 +10189,10 @@ end --> if not window
local skin_object = editing_instance:GetSkin()
local skin_name_formated = skin:gsub (" ", "")
_G.DetailsOptionsWindow3ChatTabEmbedEnabledSlider.MyObject:SetValue (_detalhes.chat_tab_embed.enabled)
_G.DetailsOptionsWindow3ChatTabEmbedNameEntry.MyObject.text = _detalhes.chat_tab_embed.tab_name
_G.DetailsOptionsWindow3ChatTabEmbed2WindowsSlider.MyObject:SetValue (_detalhes.chat_tab_embed.single_window)
--> hide all
for name, _ in pairs (_detalhes.skins) do
local name = name:gsub (" ", "")
@@ -10154,13 +10206,14 @@ end --> if not window
frame:Hide()
end
--> create or show options if necessary
--> create or show options if necessary ~extra
if (skin_object.skin_options and not skin_object.options_created) then
skin_object.options_created = true
local f = CreateFrame ("frame", "DetailsSkinOptions" .. skin_name_formated, frame3)
frame3.ExtraOptions [skin_name_formated] = f
f:SetPoint ("topleft", frame3, "topleft", window.right_start_at, window.top_start_at + (25 * -1))
f:SetPoint ("topleft", frame3.SkinExtraOptionsAnchor.widget, "bottomleft", 0, -10)
f:SetSize (250, 400)
g:BuildMenu (f, skin_object.skin_options, 0, 0, 400)
+5
View File
@@ -542,6 +542,11 @@ function _G._detalhes:Start()
wipe (_detalhes.cached_specs)
wipe (_detalhes.cached_talents)
end
_detalhes.chat_embed:CheckChatEmbed (true)
_detalhes.AddOnStartTime = GetTime()
--[[
function _detalhes:TestResize()