## XIDInterf
Class XIIIGUIButton

source: C:\XIII\XIDInterf\Classes\XIIIGuiButton.uc

    Core.Object
       |
       +--GUI.GUI
          |
          +--GUI.GUIComponent
             |
             +--GUI.GUIButton
                |
                +--XIDInterf.XIIIGUIButton

Direct Known Subclasses:None

class XIIIGUIButton
extends GUI.GUIButton

Variables
`Color` | `WhiteColor`
`bool` | `bDrawArrows`
`bool` | `bMouseEntered`
`float` | `fRatioX,fRatioY`
`sound` | `hMenuCurseur`
`XIIIRootWindow` | `myRoot`
`Texture` | `tArrow`

Function Summary
`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` | `InternalOnKeyEvent(out byte, out byte, float delta)`
`void` | `MouseEnter()`
`void` | `MouseLeave()`

Source Code

    00001	class XIIIGUIButton extends GUIButton;
    00002
    00003	var XIIIRootWindow myRoot;
    00004	var sound hMenuCurseur;
    00005	var bool bMouseEntered;
    00006
    00007	var float fRatioX,fRatioY;
    00008	var Color WhiteColor;
    00009	var Texture tArrow;
    00010	var bool bDrawArrows;
    00011
    00012	function InitComponent(GUIController MyController, GUIComponent MyOwner)
    00013	{
    00014		Super.InitComponent(MyController, MyOwner);
    00015	    OnActivate = MouseEnter;
    00016	    OnDeActivate = MouseLeave;
    00017	  if (XIIIWindow(MenuOwner) != none)
    00018		  myRoot = XIIIWindow(MenuOwner).myRoot;
    00019
    00020		OnDraw = InternalOnDraw;
    00021	  if (WinWidth<1)
    00022	  {
    00023	    WinWidth *= 640;
    00024	    WinHeight *= 480;
    00025	    WinTop *= 480;
    00026	    WinLeft *= 640;
    00027	  }
    00028	}
    00029
    00030	function MouseEnter()
    00031	{
    00032	  if (myRoot == none && XIIIWindow(MenuOwner) != none)
    00033		  myRoot = XIIIWindow(MenuOwner).myRoot;
    00034	  bMouseEntered = true;
    00035	  if (myRoot != none)
    00036	    myRoot.GetPlayerOwner().PlayMenu(hMenuCurseur);
    00037	  SetFocus(Self);
    00038	}
    00039
    00040	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
    00041	{
    00042		if (key==0x0D && State==1)	// ENTER Pressed
    00043		{
    00044	    if (myRoot == none && XIIIWindow(MenuOwner) != none)
    00045	  	  myRoot = XIIIWindow(MenuOwner).myRoot;
    00046	    myRoot.GetPlayerOwner().PlayMenu(hMenuCurseur);
    00047		}
    00048	  return super.InternalOnKeyEvent(Key, State, delta);
    00049	}
    00050
    00051	final function DrawStretchedTexture( Canvas C, float X, float Y, float W, float H, texture Tex)
    00052	{
    00053		local float OrgX, OrgY, ClipX, ClipY, nx, ny;
    00054
    00055		if (W <= 1) W = W*640*fRatioX;
    00056	    if (H <= 1) H = H*480*fRatioY;
    00057		OrgX = C.OrgX; OrgY = C.OrgY;
    00058		ClipX = C.ClipX; ClipY = C.ClipY;
    00059	    nx = WinLeft*640*fRatioX;
    00060	    ny = WinTop*480*fRatioY;
    00061	    if (myRoot.bMapMenu || XIIIWindow(MenuOwner).bCenterInGame)
    00062	    {
    00063	        if (C.ClipX > 800)
    00064	            nx = WinLeft*640*fRatioX + (C.ClipX-800)/2;
    00065	        if (C.ClipY > 600)
    00066	            ny = WinTop*480*fRatioY + (C.ClipY-600)/2;
    00067	        C.SetOrigin(nx, ny);
    00068	    }
    00069	    else
    00070	        C.SetOrigin(WinLeft*640*fRatioX, WinTop*480*fRatioY);
    00071		//C.SetClip(WinWidth*ClipX, WinHeight*ClipY);
    00072		log("Test "$Tex.USize);
    00073		C.SetPos(X, Y);
    00074	    C.DrawTileClipped( Tex, W, H, 0, 0, Tex.USize, Tex.VSize);
    00075		C.SetClip(ClipX, ClipY);
    00076		C.SetOrigin(OrgX, OrgY);
    00077	}
    00078
    00079	function bool InternalOnDraw(Canvas C)
    00080	{
    00081	  /*
    00082	  local int X,Y;
    00083	  fRatioX = XIIIWindow(MenuOwner).fRatioX;
    00084	  fRatioY = XIIIWindow(MenuOwner).fRatioY;
    00085	  X = 10;
    00086	  Y = 10;
    00087	  if (myRoot == none && XIIIWindow(MenuOwner) != none)
    00088		  myRoot = XIIIWindow(MenuOwner).myRoot;
    00089
    00090		log("Test "$fRatioY$" "$WinWidth$" "$WinHeight$" "$Tex.USize);
    00091		//DrawStretchedTexture(C, 0, 0, FirstBoxWidth - 32*fRatioX, WinHeight*480*fRatioY, myRoot.FondMenu);
    00092		DrawStretchedTexture(C, X - 16*fRatioX, Y, 16*fRatioX, WinHeight*480*fRatioY, myRoot.FondMenu);
    00093		DrawStretchedTexture(C, 0, 0, 64, 64, myRoot.FondMenu);
    00094		return true;
    00095		*/
    00096		local float OrgX, OrgY, ClipX, ClipY, nx, ny;
    00097
    00098	  if (!bDrawArrows)
    00099	    return false;
    00100
    00101	  if (MenuState != MSAT_Focused)
    00102	    return false;
    00103
    00104	  fRatioX = 1;//XIIIWindow(MenuOwner).fRatioX;
    00105	  fRatioY = 1;//XIIIWindow(MenuOwner).fRatioY;
    00106
    00107		OrgX = C.OrgX; OrgY = C.OrgY;
    00108		ClipX = C.ClipX; ClipY = C.ClipY;
    00109	  nx = WinLeft*640*fRatioX;
    00110	  ny = WinTop*480*fRatioY;
    00111
    00112	  C.SetOrigin(0/*WinLeft*fRatioX*/, 0/*WinTop*fRatioY*/);
    00113
    00114	  //C.BorderColor = DarkColor;
    00115	  C.DrawColor = WhiteColor;
    00116
    00117	  //C.DrawLine( 0,0,500,500, WhiteColor );
    00118	  C.SetPos(WinLeft*fRatioX-28, WinTop*fRatioY+2);
    00119	  C.DrawTile( tArrow, 24, WinHeight*fRatioY-4, 0, 0, -tArrow.USize, tArrow.VSize);
    00120
    00121	  C.SetPos((WinLeft+WinWidth)*fRatioX+4, WinTop*fRatioY+2);
    00122	  C.DrawTile( tArrow, 24, WinHeight*fRatioY-4, 0, 0, tArrow.USize, tArrow.VSize);
    00123		//DrawStretchedTexture(C, 0, 0, 64, 64, myRoot.FondMenu);
    00124		//DrawStretchedTexture(C, nx - 16*fRatioX, ny, 16*fRatioX, WinHeight*480*fRatioY, myRoot.FondMenu);
    00125
    00126	  C.SetOrigin(OrgX, OrgY);
    00127	  return true;
    00128	}
    00129
    00130	function MouseLeave()
    00131	{
    00132	    bMouseEntered = false;
    00133	}
    00134
    00135
    00136
    00137	defaultproperties
    00138	{
    00139	     hMenuCurseur=Sound'XIIIsound.Interface.MnCurseur'
    00140	     WhiteColor=(B=255,G=255,R=255,A=255)
    00141	     tArrow=Texture'XIIIMenuStart.Interface_LoadGame.fleches'
    00142	     StyleName="SquareButton"
    00143	}

End Source Code