XIDInterf
Class XIIIGUIBaseButton

source: C:\XIII\XIDInterf\Classes\XIIIGUIBaseButton.uc
Core.Object
   |
   +--GUI.GUI
      |
      +--GUI.GUIComponent
         |
         +--GUI.GUILabel
            |
            +--XIDInterf.XIIIGUIBaseButton
Direct Known Subclasses:XIIIArrowButton, XIIIButton, XIIICheckBoxControl, XIIIComboControl, XIIIEditCtrl, XIIIHSliderControl, XIIIInputConfigButton, XIIIMemoControl, XIIITextureButton, XIIIValueControl, XIIIVideoComboControl

class XIIIGUIBaseButton
extends GUI.GUILabel


Variables
 DarkColor, BackColor
 string Text
 bMouseEntered, bSmallFont
 fRatioX, fRatioY
 sound hMenuCurseur
 XIIIRootWindow myRoot


Function Summary
 void AfterPaint(Canvas C, float X, float Y)
 void BeforePaint(Canvas C, float X, float Y)
 void Created()
 void DrawStretchedTexture(Canvas C, float X, float Y, float W, float H, Texture Tex)
 void InitComponent(GUIController MyController, GUIComponent MyOwner)
 bool InternalOnDraw(Canvas C)
 bool InternalOnPreDraw(Canvas C)
 void MouseEnter()
 void MouseLeave()
 void Paint(Canvas C, float X, float Y)
 void SetTextColor(color NewCol)



Source Code


00001	class XIIIGUIBaseButton extends GUILabel;
00002	
00003	var XIIIRootWindow myRoot;
00004	var string Text;
00005	var color     TextCol, TextHighlightCol, DarkColor, BackColor;
00006	var bool bMouseEntered, bSmallFont;
00007	var float fRatioX, fRatioY;
00008	var sound hMenuCurseur;
00009	
00010	function InitComponent(GUIController MyController, GUIComponent MyOwner)
00011	{
00012	    Created();
00013		Super.InitComponent(MyController, MyOwner);
00014	    OnActivate = MouseEnter;
00015	    OnDeActivate = MouseLeave;
00016	    OnPreDraw = InternalOnPreDraw;
00017		OnDraw = internalOnDraw;
00018		myRoot = XIIIWindow(MenuOwner).myRoot;
00019	//    Caption = Text; // temporary ?
00020	}
00021	
00022	
00023	function Created();
00024	
00025	
00026	function bool InternalOnPreDraw(Canvas C)
00027	{
00028		local float OrgX, OrgY, nx, ny;
00029	
00030	  if (XIIIPlayerController(XIIIWindow(MenuOwner).GetPlayerOwner()) != none && XIIIPlayerController(XIIIWindow(MenuOwner).GetPlayerOwner()).bRenderPortal)
00031	    return true;
00032	
00033	    fRatioX = XIIIWindow(MenuOwner).fRatioX;
00034	    fRatioY = XIIIWindow(MenuOwner).fRatioY;
00035	
00036		OrgX = C.OrgX; 
00037	    OrgY = C.OrgY;
00038	    nx = WinLeft*640*fRatioX; 
00039	    ny = WinTop*480*fRatioY;
00040	    if (myRoot.bMapMenu || XIIIWindow(MenuOwner).bCenterInGame)
00041	    {
00042	        if (C.ClipX > 800) 
00043	            nx = WinLeft*640*fRatioX + (C.ClipX-800)/2;
00044	        if (C.ClipY > 600) 
00045	            ny = WinTop*480*fRatioY + (C.ClipY-600)/2;
00046	        C.SetOrigin(nx, ny);
00047	        Bounds[0] = nx; 
00048	        Bounds[1] = ny;
00049	        Bounds[2] = WinWidth*640*fRatioX + Bounds[0]; 
00050	        Bounds[3] = WinHeight*480*fRatioY + Bounds[1];
00051	    }
00052		else
00053	        C.SetOrigin(WinLeft*640*fRatioX, WinTop*480*fRatioY);
00054	    C.Font = font'XIIIFonts.PoliceF16';
00055	    //if ((myRoot.bIamInMulti) && (myRoot.GetLevel().NetMode == 0))
00056	    //{
00057	    //    C.Font = font'XIIIFonts.XIIIConsoleFont';
00058	    //    Text = caps(Text);
00059	    //}
00060	    BeforePaint(C, 0, 0);
00061	
00062		C.SetOrigin(OrgX, OrgY);
00063	    return true;
00064	}
00065	
00066	
00067	function bool InternalOnDraw(Canvas C)
00068	{
00069		local float OrgX, OrgY, ClipX, ClipY, nx, ny;
00070	  if (XIIIPlayerController(XIIIWindow(MenuOwner).GetPlayerOwner()) != none && XIIIPlayerController(XIIIWindow(MenuOwner).GetPlayerOwner()).bRenderPortal)
00071	    return true;
00072	
00073	    fRatioX = XIIIWindow(MenuOwner).fRatioX;
00074	    fRatioY = XIIIWindow(MenuOwner).fRatioY;
00075	
00076		OrgX = C.OrgX; OrgY = C.OrgY;
00077		ClipX = C.ClipX; ClipY = C.ClipY;
00078	    nx = WinLeft*640*fRatioX; 
00079	    ny = WinTop*480*fRatioY;
00080	    if (myRoot.bMapMenu || XIIIWindow(MenuOwner).bCenterInGame)
00081	    {
00082	        if (C.ClipX > 800) 
00083	            nx = WinLeft*640*fRatioX + (C.ClipX-800)/2;
00084	        if (C.ClipY > 600) 
00085	            ny = WinTop*480*fRatioY + (C.ClipY-600)/2;
00086	        C.SetOrigin(nx, ny);
00087	    }
00088	    else
00089	        C.SetOrigin(WinLeft*640*fRatioX, WinTop*480*fRatioY);
00090	
00091	    C.Font = font'XIIIFonts.PoliceF16';
00092	    //if ((myRoot.bIamInMulti) && (myRoot.GetLevel().NetMode == 0))
00093	    //    C.Font = font'XIIIFonts.XIIIConsoleFont';
00094	    C.BorderColor = DarkColor;
00095	    Paint(C, 0, 0);
00096	    AfterPaint(C, 0, 0);
00097	
00098	    C.SetOrigin(OrgX, OrgY);
00099	    return true;
00100	}
00101	
00102	
00103	function BeforePaint(Canvas C, float X, float Y);
00104	
00105	function Paint(Canvas C, float X, float Y)
00106	{
00107	}
00108	
00109	function AfterPaint(Canvas C, float X, float Y);
00110	
00111	function MouseEnter()
00112	{
00113	    bMouseEntered = true;
00114	    myRoot.GetPlayerOwner().PlayMenu(hMenuCurseur);
00115	    SetFocus(Self);
00116	}
00117	
00118	function MouseLeave()
00119	{
00120	    bMouseEntered = false;
00121	}
00122	
00123	
00124	function SetTextColor(color NewCol)
00125	{
00126	    TextColor = NewCol;
00127	}
00128	
00129	final function DrawStretchedTexture( Canvas C, float X, float Y, float W, float H, texture Tex)
00130	{
00131		local float OrgX, OrgY, ClipX, ClipY, nx, ny;
00132	
00133		if (W <= 1) W = W*640*fRatioX;
00134	    if (H <= 1) H = H*480*fRatioY;
00135		OrgX = C.OrgX; OrgY = C.OrgY;
00136		ClipX = C.ClipX; ClipY = C.ClipY;
00137	    nx = WinLeft*640*fRatioX; 
00138	    ny = WinTop*480*fRatioY;
00139	    if (myRoot.bMapMenu || XIIIWindow(MenuOwner).bCenterInGame)
00140	    {
00141	        if (C.ClipX > 800) 
00142	            nx = WinLeft*640*fRatioX + (C.ClipX-800)/2;
00143	        if (C.ClipY > 600) 
00144	            ny = WinTop*480*fRatioY + (C.ClipY-600)/2;
00145	        C.SetOrigin(nx, ny);
00146	    }
00147	    else
00148	        C.SetOrigin(WinLeft*640*fRatioX, WinTop*480*fRatioY);
00149		C.SetClip(WinWidth*ClipX, WinHeight*ClipY);
00150		C.SetPos(X, Y);
00151	    C.DrawTileClipped( Tex, W, H, 0, 0, Tex.USize, Tex.VSize);
00152		C.SetClip(ClipX, ClipY);
00153		C.SetOrigin(OrgX, OrgY);
00154	}
00155	
00156	
00157	
00158	defaultproperties
00159	{
00160	     TextCol=(B=50,G=160,R=255,A=255)
00161	     TextHighlightCol=(A=255)
00162	     DarkColor=(A=255)
00163	     BackColor=(B=255,G=255,R=255,A=255)
00164	     hMenuCurseur=Sound'XIIIsound.Interface.MnCurseur'
00165	     bAcceptsInput=True
00166	     bCaptureMouse=True
00167	     bTabStop=True
00168	     bFocusOnWatch=True
00169	}

End Source Code