UMenu
Class UMenuWeaponPriorityListBox

source: e:\games\UnrealTournament\UMenu\Classes\UMenuWeaponPriorityListBox.uc
Core.Object
   |
   +--UWindow.UWindowBase
      |
      +--UWindow.UWindowWindow
         |
         +--UWindow.UWindowDialogControl
            |
            +--UWindow.UWindowListControl
               |
               +--UWindow.UWindowListBox
                  |
                  +--UMenu.UMenuWeaponPriorityListBox
Direct Known Subclasses:UTWeaponPriorityListBox

class UMenuWeaponPriorityListBox
extends UWindow.UWindowListBox


Variables
 UMenuWeaponPriorityMesh MeshWindow
 string WeaponClassParent
 string WeaponPriorityHelp


Function Summary
 void Created()
 void DrawItem(Canvas C, UWindowList Item, float X, float Y, float W, float H)
 void LMouseDown(float X, float Y)
 void SaveConfigs()
 void SelectWeapon()



Source Code


00001	class UMenuWeaponPriorityListBox extends UWindowListBox;
00002	
00003	var string WeaponClassParent;
00004	var UMenuWeaponPriorityMesh MeshWindow;
00005	
00006	var localized string WeaponPriorityHelp;
00007	
00008	function Created()
00009	{
00010		local name PriorityName;
00011		local string WeaponClassName;
00012		local class<Weapon> WeaponClass;
00013		local int WeaponNum, i;
00014		local UMenuWeaponPriorityList L;
00015		local PlayerPawn P;
00016	
00017		Super.Created();
00018	
00019		SetHelpText(WeaponPriorityHelp);
00020	
00021		P = GetPlayerOwner();
00022	
00023		// Load weapons into the list
00024		for(i=0;i<ArrayCount(P.WeaponPriority);i++)
00025		{
00026			PriorityName = P.WeaponPriority[i];
00027			if(PriorityName == 'None') break;
00028			L = UMenuWeaponPriorityList(Items.Insert(ListClass));
00029			L.PriorityName = PriorityName;
00030			L.WeaponName = "(unk) "$PriorityName;
00031		}
00032	
00033		WeaponNum = 1;
00034		WeaponClassName = P.GetNextInt(WeaponClassParent, 0);
00035		while( WeaponClassName != "" && WeaponNum < 50 )
00036		{
00037			for(L = UMenuWeaponPriorityList(Items.Next); L != None; L = UMenuWeaponPriorityList(L.Next))
00038			{
00039				if( string(L.PriorityName) ~= P.GetItemName(WeaponClassName) )
00040				{
00041					L.WeaponClassName = WeaponClassName;
00042					L.bFound = True;
00043					if( L.ShowThisItem() )
00044					{
00045						WeaponClass = class<Weapon>(DynamicLoadObject(WeaponClassName, class'Class'));
00046						ReadWeapon(L, WeaponClass);
00047					}
00048					else
00049						L.bFound = False;
00050					break;
00051				}
00052			}
00053	
00054			WeaponClassName = P.GetNextInt(WeaponClassParent, WeaponNum);
00055			WeaponNum++;
00056		}
00057	}
00058	
00059	function ReadWeapon(UMenuWeaponPriorityList L, class<Weapon> WeaponClass)
00060	{
00061		L.WeaponName = WeaponClass.default.ItemName;
00062		L.WeaponMesh = WeaponClass.default.Mesh;
00063		L.WeaponSkin = WeaponClass.default.Skin;
00064	}
00065	
00066	function DrawItem(Canvas C, UWindowList Item, float X, float Y, float W, float H)
00067	{
00068		if(UMenuWeaponPriorityList(Item).bSelected)
00069		{
00070			C.DrawColor.r = 0;
00071			C.DrawColor.g = 0;
00072			C.DrawColor.b = 128;
00073			DrawStretchedTexture(C, X, Y, W, H-1, Texture'WhiteTexture');
00074			C.DrawColor.r = 255;
00075			C.DrawColor.g = 255;
00076			C.DrawColor.b = 255;
00077		}
00078		else
00079		{
00080			C.DrawColor.r = 0;
00081			C.DrawColor.g = 0;
00082			C.DrawColor.b = 0;
00083		}
00084	
00085	
00086		C.Font = Root.Fonts[F_Normal];
00087	
00088		ClipText(C, X+1, Y, UMenuWeaponPriorityList(Item).WeaponName);
00089	}
00090	
00091	function SaveConfigs()
00092	{
00093		local int i;
00094		local UMenuWeaponPriorityList L;
00095		local PlayerPawn P;
00096	
00097		P = GetPlayerOwner();
00098		
00099		for(L = UMenuWeaponPriorityList(Items.Last); L != None && L != Items; L = UMenuWeaponPriorityList(L.Prev))
00100		{
00101			P.WeaponPriority[i] = L.PriorityName;
00102			i++;
00103		}
00104		while(i<20)
00105		{
00106			P.WeaponPriority[i] = 'None';
00107			i++;
00108		}
00109		P.UpdateWeaponPriorities();
00110		P.SaveConfig();
00111		Super.SaveConfigs();
00112	}
00113	
00114	function LMouseDown(float X, float Y)
00115	{
00116		Super.LMouseDown(X, Y);
00117	
00118		if(SelectedItem != None)
00119			SelectWeapon();
00120	}
00121	
00122	function SelectWeapon()
00123	{
00124		if(MeshWindow == None)
00125			MeshWindow = UMenuWeaponPriorityMesh(GetParent(class'UMenuWeaponPriorityCW').FindChildWindow(class'UMenuWeaponPriorityMesh'));
00126	
00127		MeshWindow.MeshActor.Mesh = UMenuWeaponPriorityList(SelectedItem).WeaponMesh;
00128		MeshWindow.MeshActor.Skin = UMenuWeaponPriorityList(SelectedItem).WeaponSkin;
00129	}
00130	
00131	defaultproperties
00132	{
00133	     WeaponClassParent="Engine.Weapon"
00134	     WeaponPriorityHelp="Click and drag a weapon name in the list on the left to change its priority.  Weapons higher in the list have higher priority."
00135	     ItemHeight=13.000000
00136	     bCanDrag=True
00137	     ListClass=Class'UMenu.UMenuWeaponPriorityList'
00138	}

End Source Code