View Single Post
08-07-13, 04:05 AM   #53
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
Why do all this work when you can just check to see if a ChatFrame is showing?

Use the OnUpdate field and do a

Lua Code:
  1. if ChatFrame1:IsShown() then
  2. -- color method here
  3. else
  4. -- not shown method here
  5. end

Not too difficult to add additional checks to see if its being entered by the mouse to disable the updating color.

Edit: Here's my version and a rather simplified attempt to make things more straightforward and more 'universal' on all the buttons minus a simple string change.

OnLoad:
Lua Code:
  1. local font,size = self.text:GetFont()
  2. self.text:SetFont(font,size,"OUTLINE")
  3. self.text:SetJustifyH("CENTER")
  4. self.text:SetJustifyV("CENTER")
  5.  
  6. self.color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[select(2,UnitClass("player"))]
  7. self.frame = "ChatFrame1"

OnEnter:
Lua Code:
  1. self.entered = true

OnLeave:
Lua Code:
  1. self.entered = false

OnClick:
Lua Code:
  1. FCF_Tab_OnClick(_G[self.frame.."Tab"],button) -- This uses a method provided by blizzard to toggle the chat frames, this may also reshow the default chat tabs, although it's a nice shortcut for the button onclick.

OnUpdate:
Lua Code:
  1. if _G[self.frame]:IsShown() or self.entered then
  2.     self.text:SetTextColor(1,1,1)
  3. else
  4.     self.text:SetTextColor(self.color.r,self.color.g,self.color.b)
  5. end

Another nifty side effect to this is that it should also update the class color should you change it with CUSTOM_CLASS_COLORS.

Layout Export:
Code:
^1^T^SGeneral^T^Sborder_advanced^T^Senable^b^Sshow^T^SBOT^B^STOPRIGHTCORNER^B^SLEFT^B^STOPLEFTCORNER^B^SRIGHT^B^SBOTLEFTCORNER^B^STOP^B^SBOTRIGHTCORNER^B^t^t^Sparent^SUIParent^Ssub_level^N0^SanchorFrom^SCENTER^Shflip^b^Svflip^b^StileSize^N0^Sbg_texture^SSolid^Sanchor^SUIParent^Slevel^N0^Suse_absolute_bg^b^Sbg_blend^SBLEND^Stext^T^Sy^N0^Sfont^SBlizzard^SjustifyH^SCENTER^Sx^N0^Scolor^T^Sa^N1^Sr^N1^Sg^N1^Sb^N1^t^Stext^SGeneral^SjustifyV^SMIDDLE^Ssize^N12^t^Sy^S0^Sx^S-100^Sbg_alpha^N1^Sborder_edgeSize^N16^Sheight^S25^Stiling^b^Sstrata^SBACKGROUND^SanchorTo^SCENTER^Sabsolute_bg^T^SLLy^N1^SLLx^N0^SLRy^N1^SLRx^N1^SURx^N1^SURy^N0^SULy^N0^SULx^N0^t^Sbg_insets^T^Sb^N4^St^N-4^Sl^N4^Sr^N-4^t^Sscripts^T^SENTER^Sself.entered~`=~`true^SLOAD^Slocal~`font,size~`=~`self.text:GetFont()~Jself.text:SetFont(font,size,"OUTLINE")~Jself.text:SetJustifyH("CENTER")~Jself.text:SetJustifyV("CENTER")~J~`~Jself.color~`=~`(CUSTOM_CLASS_COLORS~`or~`RAID_CLASS_COLORS)[select(2,UnitClass("player"))]~Jself.frame~`=~`"ChatFrame1"^SCLICK^SFCF_Tab_OnClick(_G[self.frame.."Tab"],button)^SUPDATE^Sif~`_G[self.frame]:IsShown()~`or~`self.entered~`then~Jself.text:SetTextColor(1,1,1)~Jelse~Jself.text:SetTextColor(self.color.r,self.color.g,self.color.b)~Jend^SLEAVE^Sself.entered~`=~`false^t^Sbg_style^SSOLID^Sgradient_color^T^Sa^N1^Sr^N1^Sg^N1^Sb^N1^t^Sborder_color^T^Sa^N1^Sr^N1^Sg^N1^Sb^N1^t^Sborder_texture^SBlizzard~`Tooltip^Swidth^S100^Sbg_orientation^SHORIZONTAL^Srotation^N0^Smouse^B^Sbg_color^T^Sa^N0.6^Sr^N0.3^Sg^N0.3^Sb^N0.3^t^Scrop^b^t^SCombat^T^Sborder_advanced^T^Senable^b^Sshow^T^SBOTRIGHTCORNER^B^STOPRIGHTCORNER^B^STOPLEFTCORNER^B^SBOTLEFTCORNER^B^SRIGHT^B^SLEFT^B^STOP^B^SBOT^B^t^t^Sparent^SUIParent^Ssub_level^N0^SanchorFrom^SCENTER^Shflip^b^Svflip^b^StileSize^N0^Sbg_texture^SSolid^Sanchor^SUIParent^Slevel^N0^Suse_absolute_bg^b^Sbg_blend^SBLEND^Stext^T^Sy^N0^Sx^N0^SjustifyH^SCENTER^Sfont^SBlizzard^Scolor^T^Sa^N1^Sb^N1^Sg^N1^Sr^N1^t^Stext^SCombat^SjustifyV^SMIDDLE^Ssize^N12^t^Sy^S0^Sx^S0^Sbg_alpha^N1^Sborder_edgeSize^N16^Sheight^S25^Stiling^b^Sstrata^SBACKGROUND^SanchorTo^SCENTER^Sabsolute_bg^T^SLRy^N1^SLRx^N1^SULx^N0^SULy^N0^SURy^N0^SURx^N1^SLLx^N0^SLLy^N1^t^Scrop^b^Sscripts^T^SENTER^Sself.entered~`=~`true^SLOAD^Slocal~`font,size~`=~`self.text:GetFont()~Jself.text:SetFont(font,size,"OUTLINE")~Jself.text:SetJustifyH("CENTER")~Jself.text:SetJustifyV("CENTER")~J~`~Jself.color~`=~`(CUSTOM_CLASS_COLORS~`or~`RAID_CLASS_COLORS)[select(2,UnitClass("player"))]~Jself.frame~`=~`"ChatFrame2"^SCLICK^SFCF_Tab_OnClick(_G[self.frame.."Tab"],button)^SUPDATE^Sif~`_G[self.frame]:IsShown()~`or~`self.entered~`then~Jself.text:SetTextColor(1,1,1)~Jelse~Jself.text:SetTextColor(self.color.r,self.color.g,self.color.b)~Jend^SLEAVE^Sself.entered~`=~`false^t^Sbg_style^SSOLID^Sgradient_color^T^Sa^N1^Sb^N1^Sg^N1^Sr^N1^t^Sborder_color^T^Sa^N1^Sb^N1^Sg^N1^Sr^N1^t^Sborder_texture^SBlizzard~`Tooltip^Swidth^S100^Sbg_insets^T^Sr^N-4^St^N-4^Sl^N4^Sb^N4^t^Sbg_color^T^Sa^N0.6^Sb^N0.3^Sg^N0.3^Sr^N0.3^t^Smouse^B^Srotation^N0^Sbg_orientation^SHORIZONTAL^t^SLoot^T^Sborder_advanced^T^Senable^b^Sshow^T^SBOT^B^STOPRIGHTCORNER^B^SLEFT^B^SBOTLEFTCORNER^B^SRIGHT^B^STOPLEFTCORNER^B^STOP^B^SBOTRIGHTCORNER^B^t^t^Sparent^SUIParent^Sbg_orientation^SHORIZONTAL^SanchorFrom^SCENTER^Shflip^b^Svflip^b^StileSize^N0^Sbg_texture^SSolid^Sanchor^SUIParent^Slevel^N0^Suse_absolute_bg^b^Sbg_blend^SBLEND^Stext^T^Sy^N0^Sx^N0^SjustifyH^SCENTER^Sfont^SBlizzard^Scolor^T^Sa^N1^Sr^N1^Sg^N1^Sb^N1^t^Stext^SLoot^SjustifyV^SMIDDLE^Ssize^N12^t^Sy^S0^Sx^S100^Sbg_alpha^N1^Sborder_edgeSize^N16^Sheight^S25^Stiling^b^Sstrata^SBACKGROUND^SanchorTo^SCENTER^Sabsolute_bg^T^SULx^N0^SULy^N0^SLLy^N1^SLLx^N0^SURx^N1^SURy^N0^SLRx^N1^SLRy^N1^t^Sbg_insets^T^Sb^N4^St^N-4^Sl^N4^Sr^N-4^t^Sscripts^T^SENTER^Sself.entered~`=~`true^SLOAD^Slocal~`font,size~`=~`self.text:GetFont()~Jself.text:SetFont(font,size,"OUTLINE")~Jself.text:SetJustifyH("CENTER")~Jself.text:SetJustifyV("CENTER")~J~`~Jself.color~`=~`(CUSTOM_CLASS_COLORS~`or~`RAID_CLASS_COLORS)[select(2,UnitClass("player"))]~Jself.frame~`=~`"ChatFrame4"^SCLICK^SFCF_Tab_OnClick(_G[self.frame.."Tab"],button)^SUPDATE^Sif~`_G[self.frame]:IsShown()~`or~`self.entered~`then~Jself.text:SetTextColor(1,1,1)~Jelse~Jself.text:SetTextColor(self.color.r,self.color.g,self.color.b)~Jend^SLEAVE^Sself.entered~`=~`false^t^Sbg_style^SSOLID^Sgradient_color^T^Sa^N1^Sr^N1^Sg^N1^Sb^N1^t^Sborder_color^T^Sa^N1^Sr^N1^Sg^N1^Sb^N1^t^Sborder_texture^SBlizzard~`Tooltip^Swidth^S100^Ssub_level^N0^Srotation^N0^Smouse^b^Sbg_color^T^Sa^N0.6^Sr^N0.3^Sg^N0.3^Sb^N0.3^t^Scrop^b^t^t^^ayer"))])~Jself.frame~`=~`"ChatFrame1"^SCLICK^SFCF_Tab_OnClick(_G[self.frame.."Tab"],button)^SUPDATE^Sif~`_G[self.frame]:IsShown()~`or~`self.entered~`then~Jself.text:SetTextColor(1,1,1)~Jelse~Jself.text:SetTextColor(self.color.r,self.color.g,self.color.b)~Jend^SLEAVE^Sself.entered~`=~`false^t^Sbg_style^SSOLID^Sgradient_color^T^Sa^N1^Sb^N1^Sg^N1^Sr^N1^t^Sborder_color^T^Sa^N1^Sb^N1^Sg^N1^Sr^N1^t^Sborder_texture^SBlizzard~`Tooltip^Swidth^S100^Sbg_insets^T^Sr^N-4^St^N-4^Sl^N4^Sb^N4^t^Sbg_color^T^Sa^N0.6^Sb^N0.3^Sg^N0.3^Sr^N0.3^t^Smouse^B^Srotation^N0^Sbg_orientation^SHORIZONTAL^t^t^^

Last edited by suicidalkatt : 08-07-13 at 05:26 AM.
  Reply With Quote