XIDInterf
Class XIIIButton

source: C:\XIII\XIDInterf\Classes\XIIIButton.uc
Core.Object
   |
   +--GUI.GUI
      |
      +--GUI.GUIComponent
         |
         +--GUI.GUILabel
            |
            +--XIDInterf.XIIIGUIBaseButton
               |
               +--XIDInterf.XIIIButton
Direct Known Subclasses:XIIIPadButtonBase

class XIIIButton
extends XIDInterf.XIIIGUIBaseButton


Variables
 color BoxColor
 int NbMultiSplit
 TextX, TextY
 bfadein, bflash
 fadevalue, speed


Function Summary
 void BeforePaint(Canvas C, float X, float Y)
     
//____________________________________________________________________
// MLK    Set the text font and position
 void Paint(Canvas C, float X, float Y)
     
//____________________________________________________________________
// MLK    Print the text clipped to the dimensions of the button
 void ResetTextColor()
 void created()



Source Code


00001	class XIIIButton extends XIIIGUIBaseButton;
00002	
00003	var  int       TextX, TextY;
00004	var int fadevalue, speed;
00005	var bool bGlassLook, bUseBorder, bNoBg, bfadein, bflash;
00006	var int NbMultiSplit;
00007	var color BoxColor;
00008	
00009	
00010	function created()
00011	{
00012	    super.created();
00013	    TextAlign = TXTA_Center;
00014	}
00015	
00016	
00017	function ResetTextColor()
00018	{
00019	     if (myRoot.bIamInGame || myRoot.bIamInMulti) 
00020	         SetTextColor(BackColor);
00021	     else 
00022	         SetTextColor(TextCol);
00023	}
00024	
00025	
00026	//____________________________________________________________________
00027	// MLK    Set the text font and position
00028	function BeforePaint(Canvas C,float X, float Y)
00029	{
00030		local float W, H;
00031	
00032	    //if ((myRoot.bIamInMulti) && (myRoot.GetLevel().NetMode == 0))
00033	    //    C.Font = font'XIIIFonts.XIIIConsoleFont';
00034	    //else 
00035		C.Font = font'XIIIFonts.PoliceF16';
00036		C.TextSize(/*CAPS*/(Text), W, H);
00037	
00038		if ( NbMultiSplit >= 2 )
00039		{
00040			if ( NbMultiSplit == 2 )
00041			{
00042				// split screen mode with two viewports
00043				if (TextAlign == TXTA_Center) 
00044					TextX = (WinWidth*640 - W)/2;
00045				TextY = (WinHeight*480 - H)/8;
00046			}
00047			else
00048			{
00049				// split screen mode with four viewports
00050				if (TextAlign == TXTA_Center) 
00051					TextX = (WinWidth*640/2 - W)/2;
00052				TextY = (WinHeight*480 - H)/8;
00053			}
00054		}
00055		else
00056		{
00057			if (TextAlign == TXTA_Center) 
00058				TextX = Max(0,(WinWidth*640*fRatioX - W)/2);
00059			TextY = (WinHeight*480*fRatioY - H)/2;
00060		}
00061	
00062		if (bfadein) 
00063		{
00064			fadevalue+=speed; 
00065			if (fadevalue > 255) 
00066			{
00067				bfadein = false; 
00068				fadevalue = 255;
00069			}
00070		}
00071		if (bflash) 
00072		{
00073			fadevalue+=speed; 
00074			if (fadevalue > 254) 
00075			{
00076				fadevalue = 255; 
00077				speed = -speed/2;
00078			}
00079			if (fadevalue < 0) 
00080			{
00081				bflash = false; 
00082				speed = 8; 
00083			}
00084		}
00085	}
00086	
00087	
00088	//____________________________________________________________________
00089	// MLK    Print the text clipped to the dimensions of the button
00090	function Paint(Canvas C, float X, float Y)
00091	{
00092		LOCAL int OldClipX;
00093	//    if (C.Viewport != myRoot.ViewportOwner) return;
00094	    super.Paint(C,X,Y);
00095	
00096	    //if ((myRoot.bIamInMulti) && (myRoot.GetLevel().NetMode == 0))
00097	    //    C.Font = font'XIIIFonts.XIIISmallFont';
00098	    //else 
00099	        C.Font = font'XIIIFonts.PoliceF16';
00100	
00101	    C.Style = 5;
00102	    if (!bNoBg) 
00103	    {
00104	        if ( BoxColor != BackColor )
00105			{
00106				C.DrawColor = BoxColor;
00107				if (bGlassLook) 
00108				{
00109					if (bHasFocus) 
00110						C.DrawColor.A = 240;
00111					else 
00112						C.DrawColor.A = 208;
00113				}
00114			}
00115			else
00116			{
00117				C.DrawColor = BackColor;
00118				if (bGlassLook) 
00119				{
00120					if (bHasFocus) 
00121						C.DrawColor.A = 255;
00122					else 
00123						C.DrawColor.A = 128;
00124				}
00125			}
00126	        C.bUseBorder = bUseBorder;
00127	        DrawStretchedTexture(C, 0, 0, WinWidth, WinHeight, myRoot.FondMenu);
00128	        C.bUseBorder = false;
00129	    }
00130	    else 
00131	    {
00132	        if (bHasFocus) 
00133	            TextColor.A = 255;
00134	        else 
00135	            TextColor.A = 128;
00136	    }
00137	    if(Text!= "")
00138	    {
00139	        C.DrawColor = TextColor;
00140	        if (bfadein || bflash) 
00141	        {
00142	            C.Style = 5; 
00143	            C.DrawColor.A = fadevalue;
00144	        }
00145	        else 
00146	            C.Style = 1;
00147	        C.SetPos(TextX, TextY);
00148			OldClipX = C.ClipX;
00149			C.ClipX = WinWidth*640*fRatioX-2;
00150	        C.DrawTextClipped(Text, false);
00151			C.ClipX = OldClipX;
00152	    }
00153	    C.Style = 1;
00154	}
00155	
00156	
00157	
00158	
00159	defaultproperties
00160	{
00161	     Speed=4
00162	     bGlassLook=True
00163	     bUseBorder=True
00164	     BoxColor=(B=255,G=255,R=255,A=255)
00165	}

End Source Code