Go Back   WowAce Forums > General > Lua Code Discussion
Lua Code Discussion You scared? Terrified. Mortified. Petrified. Stupefied... by [coding].

Reply
 
Thread Tools
Old 05-17-2010   #1
Galvin
Senior Member
 
Join Date: Aug 2005
Posts: 433
Default How to change the alpha of chat tabs?

In the new patch 3.3.5 the chat tabs don't go totally invisible. Is there a way to make them work like they used to thru some API function?
Galvin is offline   Reply With Quote
Old 05-22-2010   #2
Phanx
Seal Cub Clubbing Club
 
Phanx's Avatar
 
Join Date: May 2005
Location: United States
Posts: 8,103
Default Re: How to change the alpha of chat tabs?

I spent some time last night fixing the 3.3.5 chat frame to look and act more like the chat frame we've all been using just fine for the last 5 years. You can see the results in the latest beta for PhanxChat over on WoWI, but here are the relevant code bits:

1. Overwrite some globals:
Code:
CHAT_FRAME_FADE_OUT_TIME = 0
-- Seconds to wait before fading out chat frames the mouse moves out of.
-- Default is 2.

CHAT_TAB_HIDE_DELAY = 0
-- Seconds to wait before fading out chat tabs the mouse moves out of.
-- Default is 1.

CHAT_FRAME_TAB_SELECTED_MOUSEOVER_ALPHA = 1
CHAT_FRAME_TAB_SELECTED_NOMOUSE_ALPHA = 0
-- Opacity of the currently selected chat tab.
-- Defaults are 1 and 0.4.

CHAT_FRAME_TAB_ALERTING_MOUSEOVER_ALPHA = 1
CHAT_FRAME_TAB_ALERTING_NOMOUSE_ALPHA = 0
-- Opacity of currently alerting chat tabs.
-- Defaults are 1 and 1.

CHAT_FRAME_TAB_NORMAL_MOUSEOVER_ALPHA = 1
CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA = 0
-- Opacity of non-selected, non-alerting chat tabs.
-- Defaults are 0.6 and 0.2.
2. Hide the new ugly "3D gloss" textures on chat tabs and restore the old highlight texture:
Code:
local noop = function() return end

for i = 1, 10 do
	local tab = _G[("ChatFrame%dTab"):format(i)]

	tab.noMouseAlpha = 0
	FCFTab_UpdateAlpha(_G[("ChatFrame%d"):format(i)])

	tab.leftSelectedTexture:SetAlpha(0)
	tab.rightSelectedTexture:SetAlpha(0)
	tab.middleSelectedTexture:SetAlpha(0)

	tab.leftHighlightTexture:SetTexture(nil)
	tab.rightHighlightTexture:SetTexture(nil)
	tab.middleHighlightTexture:SetTexture([[Interface\PaperDollInfoFrame\UI-Character-Tab-Highlight]])
	tab.middleHighlightTexture:SetWidth(76)

	tab.middleHighlightTexture.SetVertexColor = noop
end
3. Hide the new editbox "ghost", and change the actual editbox textures back to the old ones:
Code:
for i = 1, 10 do
	local editBox = _G[("ChatFrame%dEditBox"):format(i)]

	_G[("ChatFrame%sEditBoxLeft"):format(i)]:SetAlpha(0)
	_G[("ChatFrame%sEditBoxRight"):format(i)]:SetAlpha(0)
	_G[("ChatFrame%sEditBoxMid"):format(i)]:SetAlpha(0)

	editBox.focusLeft:SetTexture([[Interface\ChatFrame\UI-ChatInputBorder-Left2]])
	editBox.focusRight:SetTexture([[Interface\ChatFrame\UI-ChatInputBorder-Right2]])
	editBox.focusMid:SetTexture([[Interface\ChatFrame\UI-ChatInputBorder-Mid2]])
end
3. Hide the new friends button and "dock manager" button:
Code:
FriendsMicroButton:SetScript("OnShow", FriendsMicroButton.Hide)
FriendsMicroButton:Hide()

GeneralDockManagerOverflowButton:SetScript("OnShow", GeneralDockManagerOverflowButton.Hide)
GeneralDockManagerOverflowButton:Hide()
4. Hide the new bottom-right-corner-only resize arrow and reimplement the old all-edges resize controls (disable-on-lock stuff comes from Tekkub's tekChatBorderFix):
Code:
local anchorPoints = { "TopLeft", "TopRight", "BottomLeft", "BottomRight", "Top", "Right", "Left", "Bottom" }

local function ChatFrame_StartResizing(self)
	local chatFrame = self:GetParent()
	if chatFrame.isLocked then return end
	if chatFrame.isDocked and chatFrame ~= DEFAULT_CHAT_FRAME then return end

	chatFrame.resizing = 1
	chatFrame:StartSizing(self.anchorPoint)
end

local function ChatFrame_StopResizing(self)
	local chatFrame = self:GetParent()
	chatFrame:StopMovingOrSizing()
	if chatFrame == DEFAULT_CHAT_FRAME then
		FCF_DockUpdate()
	end
	chatFrame.resizing = nil
end

local oldSetChatWindowLocked = SetChatWindowLocked
function SetChatWindowLocked(index, locked, ...)
	local f = _G["ChatFrame" .. index]
	for _, v in ipairs(anchorPoints) do
		local k = "resize" .. v
		if f[k] then
			f[k]:EnableMouse(not locked)
		end
	end
	return oldSetChatWindowLocked(index, locked, ...)
end

for i = 1, 10 do
	local f = _G[("ChatFrame%d"):format(i)]
	if not f.resizeTopLeft then
		f.background = _G[("ChatFrame%dBackground"):format(i)]

		for _, v in ipairs(anchorPoints) do
			local k = "resize" .. v
			f[k] = CreateFrame("Button", "ChatFrame" .. i .. "Resize" .. v, f)
			f[k].anchorPoint = v:upper()
			f[k]:SetWidth(16)
			f[k]:SetHeight(16)
			f[k]:SetScript("OnMouseDown", ChatFrame_StartResizing)
			f[k]:SetScript("OnMouseUp", ChatFrame_StopResizing)
			LowerFrameLevel(f[k])
		end

		f.resizeTopLeft:SetPoint("TOPLEFT", f.background, -2, 2)

		f.resizeTopRight:SetPoint("TOPRIGHT", f.background, 2, 2)

		f.resizeBottomLeft:SetPoint("BOTTOMLEFT", f.background, -2, -3)

		f.resizeBottomRight:SetPoint("BOTTOMRIGHT", f.background, 2, -3)

		f.resizeTop:SetPoint("LEFT", f.resizeTopLeft, "RIGHT", 0, 0)
		f.resizeTop:SetPoint("RIGHT", f.resizeTopRight, "LEFT", 0, 0)

		f.resizeRight:SetPoint("TOP", f.resizeTopRight, "BOTTOM", 0, 0)
		f.resizeRight:SetPoint("BOTTOM", f.resizeBottomRight, "TOP", 0, 0)

		f.resizeBottom:SetPoint("LEFT", f.resizeBottomLeft, "RIGHT", 0, 0)
		f.resizeBottom:SetPoint("RIGHT", f.resizeBottomRight, "LEFT", 0, 0)

		f.resizeLeft:SetPoint("TOP", f.resizeTopLeft, "BOTTOM", 0, 0)
		f.resizeLeft:SetPoint("BOTTOM", f.resizeBottomLeft, "TOP", 0, 0)
	end

	local b = _G[("ChatFrame%dResizeButton"):format(i)]
	b:SetScript("OnShow", b.Hide)
	b:Hide()
end
__________________
Author/maintainer of Grid, PhanxChat, and many more. | PM me on CurseForge
Troubleshoot an addon | Turn any code into an addon | More addon resources
Need help with your code? Attach or paste your whole, real files.
Please don't PM me about addon bugs, requests, or code help. Post a comment, ticket, or thread instead!
Phanx is offline   Reply With Quote
Old 05-22-2010   #3
sylvanaar
Legendary Member
 
Join Date: Nov 2006
Posts: 2,873
Default Re: How to change the alpha of chat tabs?

If this goes beyond chat tabs, then i'll add a couple

Allow the chatframe to be moved flush with the left and bottom sides of the screen.

Code:
for i = 1, 10 do
  local cf = _G[("ChatFrame%d"):format(i)] 
  cf:SetClampRectInsets(0,0,0,0)
end
The position will not save without some extra work though, because the insets are reset in OnLoad which pushes the frames away from the side again.

Hide the new button area of the chatframe while keeping the buttons

Code:
for i = 1, 10 do
  local cf = _G[("ChatFrame%d"):format(i)]

  _G[("ChatFrame%dButtonFrameUpButton"):format(i)]:SetParent(cf)
  _G[("ChatFrame%dButtonFrameDownButton"):format(i)]:SetParent(cf)
  _G[("ChatFrame%dButtonFrameBottomButton"):format(i)]:SetParent(cf)

  _G[("ChatFrame%dButtonFrame"):format(i)]:Hide()
end
__________________
sylvanaar is offline   Reply With Quote
Old 05-23-2010   #4
Galvin
Senior Member
 
Join Date: Aug 2005
Posts: 433
Default Re: How to change the alpha of chat tabs?

Nice info. Thanks

Last edited by Galvin; 05-23-2010 at 06:54 AM.
Galvin is offline   Reply With Quote
Old 06-24-2010   #5
arnath2
Full Member
 
arnath2's Avatar
 
Join Date: Sep 2008
Posts: 181
Default Re: How to change the alpha of chat tabs?

Really unrelated question, but is the format version of this a lot more efficient or something?

Code:
_G[("ChatFrame%d"):format(i)]
versus
Code:
_G["ChatFrame" .. i]
arnath2 is offline   Reply With Quote
Old 06-24-2010   #6
Tekkub
Wiki Master
 
Tekkub's Avatar
 
Join Date: Feb 2005
Posts: 5,086
Default Re: How to change the alpha of chat tabs?

Tekkub is offline   Reply With Quote
Old 06-24-2010   #7
Phanx
Seal Cub Clubbing Club
 
Phanx's Avatar
 
Join Date: May 2005
Location: United States
Posts: 8,103
Default Re: How to change the alpha of chat tabs?

Quote:
Originally Posted by arnath2 View Post
Really unrelated question, but is the format version of this a lot more efficient or something?
Theoretically, I think so, but in practice you'd have to do it some really huge number of times before you saw an actual difference.
__________________
Author/maintainer of Grid, PhanxChat, and many more. | PM me on CurseForge
Troubleshoot an addon | Turn any code into an addon | More addon resources
Need help with your code? Attach or paste your whole, real files.
Please don't PM me about addon bugs, requests, or code help. Post a comment, ticket, or thread instead!
Phanx is offline   Reply With Quote
Old 06-24-2010   #8
kagaro
Amazing Member
 
kagaro's Avatar
 
Join Date: Aug 2008
Posts: 1,316
Default Re: How to change the alpha of chat tabs?

Quote:
Originally Posted by sylvanaar View Post
If this goes beyond chat tabs, then i'll add a couple

Allow the chatframe to be moved flush with the left and bottom sides of the screen.

Code:
for i = 1, 10 do
  local cf = _G[("ChatFrame%d"):format(i)] 
  cf:SetClampRectInsets(0,0,0,0)
end
The position will not save without some extra work though, because the insets are reset in OnLoad which pushes the frames away from the side again.

Hide the new button area of the chatframe while keeping the buttons

Code:
for i = 1, 10 do
  local cf = _G[("ChatFrame%d"):format(i)]

  _G[("ChatFrame%dButtonFrameUpButton"):format(i)]:SetParent(cf)
  _G[("ChatFrame%dButtonFrameDownButton"):format(i)]:SetParent(cf)
  _G[("ChatFrame%dButtonFrameBottomButton"):format(i)]:SetParent(cf)

  _G[("ChatFrame%dButtonFrame"):format(i)]:Hide()
end

To fix the OnLoad problem, hook the FCF_RestorePositionAndDimensions function and reset the clamp insets
__________________
author of things use the search button!
kagaro is offline   Reply With Quote
Old 06-24-2010   #9
Farmbuyer
Amazing Member
 
Farmbuyer's Avatar
 
Join Date: Feb 2005
Posts: 1,110
Default Re: How to change the alpha of chat tabs?

Quote:
Originally Posted by arnath2 View Post
Really unrelated question, but is the format version of this a lot more efficient or something?
Not for concatenating a single number; multiple ".." operations in a single statement are handled by a single operation. If you had multiple %-directives that needed to be handled, or something more complicated than %d, then yes. For (9 times out of 10) a single digit, the full-court-press string.format is a bit of an overkill. You wouldn't see a noticeable slowdown either though with only 10 loops, so pick your favorite flavor.
Farmbuyer is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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

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

Forum Jump


All times are GMT. The time now is 09:03 AM.