RMenu
Class RuneButton

source: c:\runehov\RMenu\Classes\RuneButton.uc
Core.Object
   |
   +--UWindow.UWindowBase
      |
      +--UWindow.UWindowWindow
         |
         +--UWindow.UWindowDialogControl
            |
            +--RMenu.RuneButton
Direct Known Subclasses:None

class RuneButton
extends UWindow.UWindowDialogControl

//============================================================================= // RuneButton -> Basic Button Class //=============================================================================
Variables
 Color ButtonTextCol
 Color ButtonTextHighlightCol
 OverSound, DownSound


Function Summary
 void BeforePaint(Canvas C, float X, float Y)
 
simulated
Click(float X, float Y)
     
//For notifying events
 void Created()
 
simulated
MouseEnter()
 void MouseLeave()
 void Paint(Canvas C, float X, float Y)
 void ResetTextColor()
     
//=============================================================================
// Superclass Function Overrides
//=============================================================================



Source Code


00001	//=============================================================================
00002	// RuneButton -> Basic Button Class
00003	//=============================================================================
00004	class RuneButton extends UWindowDialogControl;
00005	
00006	var		Texture		ButtonTexture;
00007	
00008	var		int			TextX,TextY;
00009	
00010	var Color ButtonTextCol;
00011	var Color ButtonTextHighlightCol;
00012	var sound OverSound, DownSound;
00013	
00014	//=============================================================================
00015	// Superclass Function Overrides
00016	//=============================================================================
00017	
00018	function ResetTextColor()
00019	{
00020		SetTextColor(ButtonTextCol);
00021	}
00022	
00023	function BeforePaint(Canvas C,float X,float Y)
00024	{	
00025		local float W, H;
00026	
00027		Super.BeforePaint(C,X,Y);
00028	
00029		C.Font = Root.Fonts[Font];
00030		
00031		TextSize(C, RemoveAmpersand(Text), W, H);
00032	
00033		TextX = (WinWidth-W)/2;
00034		TextY = (WinHeight-H)/2;
00035		TextY+=2;	//Seems to align text correctly??
00036	
00037	}
00038	
00039	function Paint(Canvas C,float X,float Y)
00040	{
00041		Super.Paint(C,X,Y);
00042	
00043		C.Font=Root.Fonts[Font];
00044	
00045		//Main Texture
00046		if (ButtonTexture!=none)
00047		{
00048			DrawStretchedTexture(C, 0, 0, WinWidth, WinHeight, ButtonTexture);
00049		}
00050	
00051		//Caption
00052		if(Text!= "")
00053		{
00054			C.DrawColor.R=0;
00055			C.DrawColor.G=0;
00056			C.DrawColor.B=0;
00057			ClipText(C,TextX+1,TextY+1,Text,True);
00058			C.DrawColor = TextColor;
00059			ClipText(C, TextX, TextY, Text, True);
00060			C.DrawColor.R = 255;
00061			C.DrawColor.G = 255;
00062			C.DrawColor.B = 255;
00063		}
00064	
00065	}
00066	
00067	//For notifying events
00068	simulated function Click(float X, float Y) 
00069	{
00070		Notify(DE_Click);
00071		if (DownSound != None)
00072		{
00073			if (GetPlayerOwner()!=None)
00074			{
00075				if (GetPlayerOwner().ViewTarget != None)
00076					GetPlayerOwner().ViewTarget.PlaySound(DownSound, SLOT_Interact);
00077				else
00078					GetPlayerOwner().PlaySound(DownSound, SLOT_Interact);
00079			}
00080		}
00081	}
00082	
00083	function Created()
00084	{
00085		Super.Created();
00086		ButtonTexture=Texture'RuneButtonBack';
00087	
00088		SetTextColor(ButtonTextCol);
00089	
00090		SetFont(F_RuneButton);
00091	}
00092	
00093	function MouseLeave()
00094	{
00095		Super.MouseLeave();
00096	
00097		SetTextColor(ButtonTextCol);
00098	
00099		if (RuneRootWindow(Root)!=None)
00100			if (RuneRootWindow(Root).StatusBar!=None)
00101				RuneRootWindow(Root).StatusBar.SetHelp("");
00102	}
00103	
00104	simulated function MouseEnter()
00105	{
00106		Super.MouseEnter();
00107		SetTextColor(ButtonTextHighlightCol);
00108	
00109		if (OverSound != None)
00110		{
00111			if (GetPlayerOwner()!=None)
00112			{
00113				if (GetPlayerOwner().ViewTarget != None)
00114					GetPlayerOwner().ViewTarget.PlaySound(OverSound, SLOT_None, , false);
00115				else
00116					GetPlayerOwner().PlaySound(OverSound, SLOT_None, , false);
00117			}
00118		}
00119	
00120		if (RuneRootWindow(Root)!=None)
00121			if (RuneRootWindow(Root).StatusBar!=None)
00122				RuneRootWindow(Root).StatusBar.SetHelp(HelpText);
00123	}
00124	
00125	defaultproperties
00126	{
00127	     ButtonTextCol=(R=250,G=250,B=250)
00128	     ButtonTextHighlightCol=(R=250)
00129	     OverSound=Sound'RMenu.TopMouseOver'
00130	     DownSound=Sound'RMenu.TopButton'
00131	}

End Source Code