XIDInterf
Class XIIIVideoComboControl

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

class XIIIVideoComboControl
extends XIDInterf.XIIIGUIBaseButton


Variables
 int BorderInX
 int Index
 Items, Items2
 TextY, TextY2
 bool bSelected
 string sBackGround
 Texture tBackGround


Function Summary
 void AddItem(string newItem, optional string)
 void AlignLeft()
 void BeforePaint(Canvas C, float X, float Y)
 void Clear()
 void Created()
 int FindItemIndex(string Value, optional bool)
 int GetIdx()
 int GetSelectedIndex()
 string GetValue()
 string GetValue2()
 bool InternalCapturedMouseMove(float deltaX, float deltaY)
 bool InternalOnKeyEvent(out byte, out byte, float delta)
 void MouseEnter()
 void MouseLeave()
 void Paint(Canvas C, float X, float Y)
 void SetSelectedIndex(int ind)



Source Code


00001	class XIIIVideoComboControl extends XIIIGUIBaseButton;
00002	
00003	var array <string> Items, Items2;
00004	var bool bSelected;
00005	var texture tBackGround;
00006	var string sBackGround;
00007	var int TextX, TextX2, TextY, TextY2;
00008	var int Index;
00009	var int BorderInX;
00010	
00011	
00012	function Created()
00013	{
00014	    super.Created();
00015	    TextAlign = TXTA_Center;
00016	    tBackGround = texture(DynamicLoadObject(sBackGround, class'Texture'));
00017	   OnKeyEvent=InternalOnKeyEvent;
00018	}
00019	
00020	function AlignLeft()
00021	{
00022	    TextAlign = TXTA_Left;
00023	}
00024	
00025	function int GetSelectedIndex()
00026	{
00027	     return Index;
00028	}
00029	
00030	function SetSelectedIndex(int ind)
00031	{
00032	     if (ind > -1) 
00033	         Index = ind;
00034	     if (ind >= Items.Length) 
00035	         Index = Items.Length-1;
00036	}
00037	
00038	function AddItem(string newItem, optional string newItem2)
00039	{
00040	     Items[Items.Length] = newItem;
00041	     if (newItem2 != "") Items2[Items2.Length] = newItem2;
00042	}
00043	
00044	function string GetValue()
00045	{
00046	     return Items[Index];
00047	}
00048	
00049	function int GetIdx()
00050	{
00051	     return Index;
00052	}
00053	
00054	function string GetValue2()
00055	{
00056	     return Items2[Index];
00057	}
00058	
00059	function Clear()
00060	{
00061	     Index = 0;
00062	     Items.Length=0;
00063	}
00064	
00065	function int FindItemIndex(string Value, optional bool bIgnoreCase)
00066	{
00067	     local int Count;
00068	
00069	     Count = 0;
00070	     while(Count < Items.Length)
00071	     {
00072	          if(bIgnoreCase && Items[Count] ~= Value) return Count;
00073	          if(Items[Count] == Value) return Count;
00074	
00075	          Count++;
00076	     }
00077	
00078	     return -1;
00079	}
00080	
00081	function BeforePaint(Canvas C, float X, float Y)
00082	{
00083	    local float W, H;
00084	
00085	    if (bSmallFont) C.Font = font'XIIIFonts.XIIIConsoleFont';
00086	    else C.Font = font'XIIIFonts.PoliceF16';
00087	    C.TextSize(Caps(Text), W, H);
00088	//    TextX = (50 + (WinWidth*640 - 100)/2)*fRatioX - W/2;
00089	    TextX = WinWidth*320*fRatioX - W/2;
00090	    TextY = (WinHeight*480*fRatioY)/7;
00091	    C.TextSize(Caps(Items[index]), W, H);
00092	    TextX2 = WinWidth*320*fRatioX - W/2;
00093	    TextY2 = 2*(WinHeight*480*fRatioY)/5;
00094	}
00095	
00096	
00097	function Paint(Canvas C, float X, float Y)
00098	{
00099	    super.Paint(C, X, Y);
00100	    C.DrawColor = BackColor;
00101	    DrawStretchedTexture(C, 0, 0, WinWidth*640*fRatioX, WinHeight*480*fRatioY, tBackGround);
00102	
00103	    C.DrawColor = TextColor;
00104	    C.Style = 5;
00105	    C.DrawColor.A = Clamp(int(bHasFocus)*255 + 128, 0, 255);
00106	
00107	    C.SetPos(TextX, TextY); C.DrawText(Caps(text), false);
00108	    C.SetPos(TextX2, TextY2); C.DrawText(Caps(Items[index]), false);
00109	    C.Style = 1;
00110	    C.DrawColor = BackColor;
00111	}
00112	
00113	
00114	function MouseEnter()
00115	{
00116	    super.MouseEnter();
00117	}
00118	
00119	function MouseLeave()
00120	{
00121	    super.MouseLeave();
00122	}
00123	
00124	function bool InternalCapturedMouseMove(float deltaX, float deltaY)
00125	{
00126		if (Controller.MouseX < (Bounds[0]+BorderInX))
00127	            SetSelectedIndex(Index-1);
00128		else if (Controller.MouseX > (Bounds[2]-BorderInX))
00129	            SetSelectedIndex(Index+1);
00130		else if ( (Controller.MouseX >= Bounds[0]) && (Controller.MouseX<=Bounds[2]) )
00131		{
00132		}
00133	
00134		return true;
00135	}
00136	
00137	
00138	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
00139	{
00140	    if (Key == 0x01)   InternalCapturedMouseMove(0,0);
00141	
00142	
00143		if ( (Key==0x25 || Key==0x64 || Key==0xEC) && ((State==1) || (State==2)))	// Left
00144		{
00145			SetSelectedIndex(Index-1);//-
00146		}
00147	
00148		if ( (Key==0x27 || Key==0x66 || Key==0xED) && ((State==1) || (State==2))) // Right
00149		{
00150			SetSelectedIndex(Index+1);//+
00151		}
00152		return false;
00153	}
00154	
00155	
00156	
00157	
00158	
00159	
00160	defaultproperties
00161	{
00162	     sBackground="XIIIMenuStart.Boutonvideo"
00163	     BorderInX=15
00164	}

End Source Code