Thread Tools Display Modes
12-05-12, 03:12 PM   #1
Blazingstorm
A Deviate Faerie Dragon
 
Blazingstorm's Avatar
Join Date: Jan 2007
Posts: 16
Chat Panels

Ok all you .lua guru's, I have a couple of Chat Panel questions. I currently use the mod nChat, for my chat mod needs. What I am looking to do is add a couple of small things (at least I hope they are small, lol).

1st: Would like to be able to set the height and width of the chat panels in the .lue file. The Blizzard drag and re-size is inaccurate.

2nd: Would like to also be able to set the position of the chat panels in the .lua file as well. (ex. BottomLeft 7,7)

3rd: If possible, have the editbox below the chat panel and possibly match the width as well.

Any help in these areas would greatly be appreciated. Thanks.
  Reply With Quote
12-05-12, 04:38 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
#1:
Code:
ChatFrame1:SetMaxResize(UIParent:GetWidth(), UIParent:GetHeight()
ChatFrame1:SetMinResize(100, 10) -- this and the previous line might not actually be needed
ChatFrame1:SetWidth(400)
ChatFrame1:SetHeight(200)
#2:
Code:
ChatFrame1:SetClampRectInsets(0, 0, 0, 0) -- needed so the game doesn't push it away from the edges
ChatFrame1:ClearAllPoints()
ChatFrame1:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 7, 7)
#3:
I'm not sure what you mean, as the chat edit box is below the chat frame and matches the width of the chat frame by default. If you're seeing something else, it means you have an addon moving and resizing the edit box.
__________________
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
12-09-12, 04:31 AM   #3
Blazingstorm
A Deviate Faerie Dragon
 
Blazingstorm's Avatar
Join Date: Jan 2007
Posts: 16
Chat Panels

Thanks for the quick response Phanx, your help is greatly appreciated. I tried entering your suggested code, and the end results are always incorrect. The General tab on the left and the Loot tab on right do not want to resize, but any other tab such as the Combat Log and Whisper tab will resize. As long as you undock them from the main chat frame.

My knowledge of .lua is sucky at best. I can make adjustments here and there, that's about it. So I have included the code of the mod I use, minus your suggested code. If you'd still like to help, that would be great. If not I understand.

As far as the EditBox goes, I figured that one out and adjusted it to my liking's.

Thanks, and keep up the great work with your own projects, and that of others.

Code:
local N, C, DB = unpack(select(2, ...)) -- Import:  N - function; C - config; DB - database

if C['nChat'].enable ~= true then return end

local _G = _G
local type = type
local select = select
local unpack = unpack

local gsub = string.gsub
local format = string.format

_G.CHAT_FRAME_TAB_SELECTED_MOUSEOVER_ALPHA = 1
_G.CHAT_FRAME_TAB_SELECTED_NOMOUSE_ALPHA = 1

_G.CHAT_FRAME_TAB_NORMAL_MOUSEOVER_ALPHA = 1
_G.CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA = 1

_G.CHAT_FRAME_FADE_OUT_TIME = 0.25
_G.CHAT_FRAME_FADE_TIME = 0.1

--[[
_G.CHAT_SAY_GET = '%s:\32'
_G.CHAT_YELL_GET = '%s:\32'

_G.CHAT_WHISPER_GET = '[from] %s:\32'
_G.CHAT_WHISPER_INFORM_GET = '[to] %s:\32'

_G.CHAT_BN_WHISPER_GET = '[from] %s:\32'
_G.CHAT_BN_WHISPER_INFORM_GET = '[to] %s:\32'
--]]

_G.CHAT_FLAG_AFK = '[AFK] '
_G.CHAT_FLAG_DND = '[DND] '
_G.CHAT_FLAG_GM = '[GM] '

_G.CHAT_GUILD_GET = '(|Hchannel:Guild|hG|h) %s:\32'
_G.CHAT_OFFICER_GET = '(|Hchannel:o|hO|h) %s:\32'

_G.CHAT_PARTY_GET = '(|Hchannel:party|hP|h) %s:\32'
_G.CHAT_PARTY_LEADER_GET = '(|Hchannel:party|hPL|h) %s:\32'
_G.CHAT_PARTY_GUIDE_GET = '(|Hchannel:party|hDG|h) %s:\32'
_G.CHAT_MONSTER_PARTY_GET = '(|Hchannel:raid|hR|h) %s:\32'

_G.CHAT_RAID_GET = '(|Hchannel:raid|hR|h) %s:\32'
_G.CHAT_RAID_WARNING_GET = '(RW!) %s:\32'
_G.CHAT_RAID_LEADER_GET = '(|Hchannel:raid|hL|h) %s:\32'

_G.CHAT_BATTLEGROUND_GET = '(|Hchannel:Battleground|hBG|h) %s:\32'
_G.CHAT_BATTLEGROUND_LEADER_GET = '(|Hchannel:Battleground|hBL|h) %s:\32'

    -- Blizzard introduced a bug in 4.3 that always enables
    -- the profanity filter

BNSetMatureLanguageFilter(false)

    -- Disable the profanity filter interface option

InterfaceOptionsSocialPanelProfanityFilter:SetAlpha(0.35)
InterfaceOptionsSocialPanelProfanityFilter:Disable()
InterfaceOptionsSocialPanelProfanityFilter:EnableMouse(false)

--[[
local channelFormat 
do
    local a, b = '.*%[(.*)%].*', '%%[%1%%]'
    channelFormat = {
        [1] = {gsub(CHAT_BATTLEGROUND_GET, a, b), '[BG]'},
        [2] = {gsub(CHAT_BATTLEGROUND_LEADER_GET, a, b), '[BGL]'},

        [3] = {gsub(CHAT_GUILD_GET, a, b), '[G]'},
        [4] = {gsub(CHAT_OFFICER_GET, a, b), '[O]'},
        
        [5] = {gsub(CHAT_PARTY_GET, a, b), '[P]'},
        [6] = {gsub(CHAT_PARTY_LEADER_GET, a, b), '[PL]'},
        [7] = {gsub(CHAT_PARTY_GUIDE_GET, a, b), '[PL]'},

        [8] = {gsub(CHAT_RAID_GET, a, b), '[R]'},
        [9] = {gsub(CHAT_RAID_LEADER_GET, a, b), '[RL]'},
        [10] = {gsub(CHAT_RAID_WARNING_GET, a, b), '[RW]'},

        [11] = {gsub(CHAT_FLAG_AFK, a, b), '[AFK] '},
        [12] = {gsub(CHAT_FLAG_DND, a, b), '[DND] '},
        [13] = {gsub(CHAT_FLAG_GM, a, b), '[GM] '},
    }
end
]]

local AddMessage = ChatFrame1.AddMessage
local function FCF_AddMessage(self, text, ...)
    if (type(text) == 'string') then
        text = gsub(text, '(|HBNplayer.-|h)%[(.-)%]|h', '%1%2|h')
        text = gsub(text, '(|Hplayer.-|h)%[(.-)%]|h', '%1%2|h')
        text = gsub(text, '%[(%d0?)%. (.-)%]', '(%1)') 
        
        --[[
        for i = 1, #channelFormat  do
            text = gsub(text, channelFormat[i][1], channelFormat[i][2])
        end
        --]]
    end

    return AddMessage(self, text, ...)
end

    -- Modify the editbox
    
for k = 6, 11 do
   select(k, ChatFrame1EditBox:GetRegions()):SetTexture(nil)
end

ChatFrame1EditBox:SetAltArrowKeyMode(false)
ChatFrame1EditBox:ClearAllPoints()
ChatFrame1EditBox:SetPoint('BOTTOMLEFT', ChatFrame1, 'BOTTOMLEFT', 2, -43)
ChatFrame1EditBox:SetPoint('BOTTOMRIGHT', ChatFrame1, 'TOPRIGHT', 0, 33)
ChatFrame1EditBox:SetBackdrop({
    bgFile = 'Interface\\Buttons\\WHITE8x8',
    insets = { 
        left = 3, right = 3, top = 2, bottom = 2 
    },
})

ChatFrame1EditBox:SetBackdropColor(0, 0, 0, 0.5)
ChatFrame1EditBox:CreateBeautyBorder(12)
ChatFrame1EditBox:SetBeautyBorderPadding(-2, -1, -2, -1, -2, -1, -2, -1)

if (C['nChat'].enableBorderColoring) then
    ChatFrame1EditBox:SetBeautyBorderTexture('white')

    hooksecurefunc('ChatEdit_UpdateHeader', function(editBox)
        local type = editBox:GetAttribute('chatType')
        if (not type) then
            return
        end

        local info = ChatTypeInfo[type]
        ChatFrame1EditBox:SetBeautyBorderColor(info.r, info.g, info.b)
    end)
end

if C['nChat'].chatBorder == true then	
	do	
		for i = 1, NUM_CHAT_WINDOWS do
			local cf = _G['ChatFrame'..i]
			if cf then
				cf:CreateBeautyBorder(12)
				cf:SetBeautyBorderPadding( 5, 5, 5, 5, 5, 8, 5, 8)
				cf:SetBeautyBorderTexture('white')
				if C['nMedia'].border == "Default" then
					cf:SetBeautyBorderColor(0.38, 0.38, 0.38)		
				elseif C['nMedia'].border == "Classcolor" then
					cf:SetBeautyBorderColor(N.ccolor.r, N.ccolor.g, N.ccolor.b)
				elseif C['nMedia'].border == "Custom" then
					cf:SetBeautyBorderColor(C['nMedia'].color.r, C['nMedia'].color.g, C['nMedia'].color.b)		
				end	
			end
		end
		
		local ct = _G['ChatFrame2']
		if ct then
			ct:CreateBeautyBorder(12)
			ct:SetBeautyBorderPadding(5, 29, 5, 29, 5, 8, 5, 8)
			ct:SetBeautyBorderTexture('white')
			if C['nMedia'].border == "Default" then
				ct:SetBeautyBorderColor(0.38, 0.38, 0.38)		
			elseif C['nMedia'].border == "Classcolor" then
				ct:SetBeautyBorderColor(N.ccolor.r, N.ccolor.g, N.ccolor.b)
			elseif C['nMedia'].border == "Custom" then
				ct:SetBeautyBorderColor(C['nMedia'].color.r, C['nMedia'].color.g, C['nMedia'].color.b)		
			end			
		end
	end
end	
    -- Hide the menu and friend button

FriendsMicroButton:SetAlpha(0)
FriendsMicroButton:EnableMouse(false)
FriendsMicroButton:UnregisterAllEvents()

ChatFrameMenuButton:SetAlpha(0)
ChatFrameMenuButton:EnableMouse(false)

    -- Tab text colors for the tabs

hooksecurefunc('FCFTab_UpdateColors', function(self, selected)
    if (selected) then
        self:GetFontString():SetTextColor(0, 0.75, 1)
    else
        self:GetFontString():SetTextColor(1, 1, 1)
    end
end)

    -- Tab text fadeout

local origFCF_FadeOutChatFrame = _G.FCF_FadeOutChatFrame
local function FCF_FadeOutChatFrameHook(chatFrame)
    origFCF_FadeOutChatFrame(chatFrame)

    local frameName = chatFrame:GetName()
    local chatTab = _G[frameName..'Tab']
    local tabGlow = _G[frameName..'TabGlow']

    if (not tabGlow:IsShown()) then
        if (frameName.isDocked) then
            securecall('UIFrameFadeOut', chatTab, CHAT_FRAME_FADE_OUT_TIME, chatTab:GetAlpha(), CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA)
        else
            securecall('UIFrameFadeOut', chatTab, CHAT_FRAME_FADE_OUT_TIME, chatTab:GetAlpha(), CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA)
        end
    end
end
FCF_FadeOutChatFrame = FCF_FadeOutChatFrameHook

    -- Improve mousewheel scrolling

hooksecurefunc('FloatingChatFrame_OnMouseScroll', function(self, direction)
    if (direction > 0) then
        if (IsShiftKeyDown()) then
            self:ScrollToTop()
        else
            self:ScrollUp()
            self:ScrollUp()
        end
    elseif (direction < 0)  then
        if (IsShiftKeyDown()) then
            self:ScrollToBottom()
        else
            self:ScrollDown()
            self:ScrollDown()
        end
    end

    if (C['nChat'].enableBottomButton) then
        local buttonBottom = _G[self:GetName() .. 'ButtonFrameBottomButton']
        if (self:AtBottom()) then
            buttonBottom:Hide()
        else
            buttonBottom:Show()
            buttonBottom:SetAlpha(0.7)
        end
    end
end)

    -- Reposit toast frame

BNToastFrame:HookScript('OnShow', function(self)
    BNToastFrame:ClearAllPoints()
    BNToastFrame:SetPoint('BOTTOMLEFT', ChatFrame1EditBox, 'TOPLEFT', 0, 15)
end)

    -- Modify the chat tabs

function SkinTab(self)
    local chat = _G[self]

    local tab = _G[self..'Tab']
    for i = 1, select('#', tab:GetRegions()) do
        local texture = select(i, tab:GetRegions())
        if (texture and texture:GetObjectType() == 'Texture') then
            texture:SetTexture(nil)
        end
    end

    local tabText = _G[self..'TabText']
    tabText:SetJustifyH('CENTER')
    tabText:SetWidth(60)
    if (C['nChat'].tab.fontOutline) then
        tabText:SetFont(C['nMedia'].font, C['nChat'].tab.fontSize, 'THINOUTLINE')
        tabText:SetShadowOffset(0, 0)
    else
        tabText:SetFont(C['nMedia'].font, C['nChat'].tab.fontSize)
        tabText:SetShadowOffset(1, -1)
    end

    local a1, a2, a3, a4, a5 = tabText:GetPoint()
    tabText:SetPoint(a1, a2, a3, a4, 1)

    local s1, s2, s3 = C['nChat'].tab.specialColor.r, C['nChat'].tab.specialColor.g, C['nChat'].tab.specialColor.b
    local e1, e2, e3 = C['nChat'].tab.selectedColor.r, C['nChat'].tab.selectedColor.g, C['nChat'].tab.selectedColor.b
    local n1, n2, n3 = C['nChat'].tab.normalColor.r, C['nChat'].tab.normalColor.g, C['nChat'].tab.normalColor.b

    local tabGlow = _G[self..'TabGlow']
    hooksecurefunc(tabGlow, 'Show', function()
        tabText:SetTextColor(s1, s2, s3, CHAT_FRAME_TAB_NORMAL_MOUSEOVER_ALPHA)
    end)

    hooksecurefunc(tabGlow, 'Hide', function()
        tabText:SetTextColor(n1, n2, n3)
    end)

    tab:SetScript('OnEnter', function()
        tabText:SetTextColor(s1, s2, s3, tabText:GetAlpha())
    end)

    tab:SetScript('OnLeave', function()
        local hasNofication = tabGlow:IsShown()

        local r, g, b
        if (_G[self] == SELECTED_CHAT_FRAME and chat.isDocked) then
            r, g, b = e1, e2, e3
        elseif (hasNofication) then
            r, g, b = s1, s2, s3
        else
            r, g, b = n1, n2, n3
        end

        tabText:SetTextColor(r, g, b)
    end)

    hooksecurefunc(tab, 'Show', function()
        if (not tab.wasShown) then
            local hasNofication = tabGlow:IsShown()
            
            if (chat:IsMouseOver()) then
                tab:SetAlpha(CHAT_FRAME_TAB_NORMAL_MOUSEOVER_ALPHA)
            else
                tab:SetAlpha(CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA)
            end

            local r, g, b
            if (_G[self] == SELECTED_CHAT_FRAME and chat.isDocked) then
                r, g, b = e1, e2, e3
            elseif (hasNofication) then
                r, g, b = s1, s2, s3
            else
                r, g, b = n1, n2, n3
            end

            tabText:SetTextColor(r, g, b)

            tab.wasShown = true
        end
    end)
end

local function ModChat(self)
    local chat = _G[self]

    if (not C['nChat'].chatOutline) then
        chat:SetShadowOffset(1, -1)
    end

    if (C['nChat'].disableFade) then
        chat:SetFading(false)
    end

    SkinTab(self)

    local font, fontsize, fontflags = chat:GetFont()
    chat:SetFont(C['nMedia'].font, fontsize, C['nChat'].chatOutline and 'THINOUTLINE' or fontflags)
    chat:SetClampedToScreen(true)

    chat:SetClampRectInsets(0, 0, 0, 0)
    chat:SetMaxResize(UIParent:GetWidth(), UIParent:GetHeight())
    chat:SetMinResize(150, 25)
    
    if (self ~= 'ChatFrame2') then
        chat.AddMessage = FCF_AddMessage
    end

    local buttonUp = _G[self..'ButtonFrameUpButton']
    buttonUp:SetAlpha(0)
    buttonUp:EnableMouse(false)

    local buttonDown = _G[self..'ButtonFrameDownButton']
    buttonDown:SetAlpha(0)
    buttonDown:EnableMouse(false)

    local buttonBottom = _G[self..'ButtonFrameBottomButton']
    if (C['nChat'].enableBottomButton) then
        buttonBottom:Hide()
        buttonBottom:ClearAllPoints()
        buttonBottom:SetPoint('BOTTOMRIGHT', chat, 1, 3)
        buttonBottom:HookScript('OnClick', function(self)
            self:Hide()
        end)
    else
        buttonBottom:SetAlpha(0)
        buttonBottom:EnableMouse(false)
    end

    for _, texture in pairs({
        'ButtonFrameBackground',
        'ButtonFrameTopLeftTexture',
        'ButtonFrameBottomLeftTexture',
        'ButtonFrameTopRightTexture',
        'ButtonFrameBottomRightTexture',
        'ButtonFrameLeftTexture',
        'ButtonFrameRightTexture',
        'ButtonFrameBottomTexture',
        'ButtonFrameTopTexture',
    }) do
        _G[self..texture]:SetTexture(nil)
    end
end

local function SetChatStyle()
    for _, v in pairs(CHAT_FRAMES) do
        local chat = _G[v]
        if (chat and not chat.hasModification) then
            ModChat(chat:GetName())

            local convButton = _G[chat:GetName()..'ConversationButton']
            if (convButton) then
                convButton:SetAlpha(0)
                convButton:EnableMouse(false)
            end

            local chatMinimize = _G[chat:GetName()..'ButtonFrameMinimizeButton']
            if (chatMinimize) then
                chatMinimize:SetAlpha(0)
                chatMinimize:EnableMouse(0)
            end

            chat.hasModification = true
        end
    end	
	
end
hooksecurefunc('FCF_OpenTemporaryWindow', SetChatStyle)
SetChatStyle()

    -- Chat menu, just a middle click on the chatframe 1 tab

hooksecurefunc('ChatFrameMenu_UpdateAnchorPoint', function()
    if (FCF_GetButtonSide(DEFAULT_CHAT_FRAME) == 'right') then
        ChatMenu:ClearAllPoints()
        ChatMenu:SetPoint('BOTTOMRIGHT', ChatFrame1Tab, 'TOPLEFT')
    else
        ChatMenu:ClearAllPoints()
        ChatMenu:SetPoint('BOTTOMLEFT', ChatFrame1Tab, 'TOPRIGHT')
    end
end)

ChatFrame1Tab:RegisterForClicks('AnyUp')
ChatFrame1Tab:HookScript('OnClick', function(self, button)
    if (button == 'MiddleButton' or button == 'Button4' or button == 'Button5') then
        if (ChatMenu:IsShown()) then
            ChatMenu:Hide()
        else
            ChatMenu:Show()
        end
    else
        ChatMenu:Hide()
    end
end)

    -- Modify the gm chatframe and add a sound notification on incoming whispers

local f = CreateFrame('Frame')
f:RegisterEvent('ADDON_LOADED')
f:RegisterEvent('CHAT_MSG_WHISPER')
f:RegisterEvent('CHAT_MSG_BN_WHISPER')
f:SetScript('OnEvent', function(_, event)
    if (event == 'ADDON_LOADED' and arg1 == 'Blizzard_GMChatUI') then
        GMChatFrame:EnableMouseWheel(true)
        GMChatFrame:SetScript('OnMouseWheel', ChatFrame1:GetScript('OnMouseWheel'))
        GMChatFrame:SetHeight(200)

        GMChatFrameUpButton:SetAlpha(0)
        GMChatFrameUpButton:EnableMouse(false)

        GMChatFrameDownButton:SetAlpha(0)
        GMChatFrameDownButton:EnableMouse(false)

        GMChatFrameBottomButton:SetAlpha(0)
        GMChatFrameBottomButton:EnableMouse(false)
    end

    if (event == 'CHAT_MSG_WHISPER' or event == 'CHAT_MSG_BN_WHISPER') then
        PlaySoundFile('Sound\\Spells\\Simongame_visual_gametick.wav')
    end
end)

local combatLog = {
    text = 'CombatLog',
    colorCode = '|cffFFD100',
    isNotRadio = true,

    func = function() 
        if (not LoggingCombat()) then
            LoggingCombat(true) 
            DEFAULT_CHAT_FRAME:AddMessage(COMBATLOGENABLED, 1, 1, 0)
        else
            LoggingCombat(false)
            DEFAULT_CHAT_FRAME:AddMessage(COMBATLOGDISABLED, 1, 1, 0)
        end
    end,

    checked = function()
        if (LoggingCombat()) then
            return true
        else
            return false
        end
    end
}

local chatLog = {
    text = 'ChatLog',
    colorCode = '|cffFFD100',
    isNotRadio = true,

    func = function() 
        if (not LoggingChat()) then
            LoggingChat(true) 
            DEFAULT_CHAT_FRAME:AddMessage(CHATLOGENABLED, 1, 1, 0)
        else
            LoggingChat(false)
            DEFAULT_CHAT_FRAME:AddMessage(CHATLOGDISABLED, 1, 1, 0)
        end
    end,

    checked = function()
        if (LoggingChat()) then
            return true
        else
            return false
        end
    end
}

local origFCF_Tab_OnClick = _G.FCF_Tab_OnClick
local function FCF_Tab_OnClickHook(chatTab, ...)
    origFCF_Tab_OnClick(chatTab, ...)

    combatLog.arg1 = chatTab
    UIDropDownMenu_AddButton(combatLog)

    chatLog.arg1 = chatTab
    UIDropDownMenu_AddButton(chatLog)
end
FCF_Tab_OnClick = FCF_Tab_OnClickHook
  Reply With Quote
12-09-12, 11:00 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I'm not sure what you mean about the resizing. If multiple chat windows are docked together, only the first one is resizable -- the others always follow the size of the first. Also, the code I posted doesn't resize tabs at all, only the actual chat frames. Can you be more specific about the problem?

Also, in the code you posted, all of those _G.SOME_VAR lookups are extremely inefficient. Just access SOME_VAR directly; it saves you a table lookup. You can also get rid of "local _G = _G" ... it makes the unnecessary table lookup a little faster, but still slower than just getting the variable directly from the global environment.
__________________
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

WoWInterface » Developer Discussions » Lua/XML Help » Chat Panels

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off