UTMenu
Class UTPlayerSetupClient

source: e:\games\UnrealTournament\UTMenu\Classes\UTPlayerSetupClient.uc
Core.Object
   |
   +--UWindow.UWindowBase
      |
      +--UWindow.UWindowWindow
         |
         +--UWindow.UWindowClientWindow
            |
            +--UWindow.UWindowDialogClientWindow
               |
               +--UMenu.UMenuDialogClientWindow
                  |
                  +--UMenu.UMenuPlayerSetupClient
                     |
                     +--UTMenu.UTPlayerSetupClient
Direct Known Subclasses:None

class UTPlayerSetupClient
extends UMenu.UMenuPlayerSetupClient


Variables
 bool ClassChanging
 string CommanderHelp;*/
 string CommanderText
 UWindowCheckbox SpectatorCheck
 string SpectatorHelp
 string SpectatorText
 UWindowSmallButton StatsButton
 string StatsButtonText
 UMenuLabelControl StatsLabel
 string StatsText
 UWindowComboControl VoicePackCombo
 string VoicePackHelp
 string VoicePackText


Function Summary
 void BeforePaint(Canvas C, float X, float Y)
 void ClassChanged()
 void CommanderChanged()
     
/*
 void Created()
     
 void IterateVoices()
 void LoadClasses()
 void LoadCurrent()
 void Notify(UWindowDialogControl C, byte E)
 void SpectatorChanged()
 void StatsPressed()
 
simulated
VoiceChanged()
     
{
	SpectatorCheck.bChecked = False;

	if(CommanderCheck.bChecked)
		GetPlayerOwner().UpdateURL("OverrideClass", "Botpack.Commander", True);
	else
		GetPlayerOwner().UpdateURL("OverrideClass", "", True);
}*/



Source Code


00001	class UTPlayerSetupClient extends UMenuPlayerSetupClient;
00002	
00003	// VoicePack
00004	var UWindowComboControl VoicePackCombo;
00005	var localized string VoicePackText;
00006	var localized string VoicePackHelp;
00007	
00008	var UWindowCheckbox SpectatorCheck;
00009	var localized string SpectatorText;
00010	var localized string SpectatorHelp;
00011	
00012	/*var UWindowCheckbox CommanderCheck;
00013	var localized string CommanderText;
00014	var localized string CommanderHelp;*/
00015	
00016	var UMenuLabelControl StatsLabel;
00017	var localized string StatsText;
00018	var UWindowSmallButton StatsButton;
00019	var localized string StatsButtonText;
00020	
00021	var bool ClassChanging;
00022	
00023	function Created()
00024	{
00025		local int ControlWidth, ControlLeft, ControlRight;
00026		local int CenterWidth, CenterPos;
00027		local int I, Num;
00028	
00029		Super.Created();
00030		
00031		DesiredWidth = 220;
00032		DesiredHeight = 80;
00033	
00034		ControlWidth = WinWidth/2.5;
00035		ControlLeft = (WinWidth/2 - ControlWidth)/2;
00036		ControlRight = WinWidth/2 + ControlLeft;
00037	
00038		CenterWidth = (WinWidth/4)*3;
00039		CenterPos = (WinWidth - CenterWidth)/2;
00040	
00041		ControlOffset += 25;
00042		VoicePackCombo = UWindowComboControl(CreateControl(class'UWindowComboControl', CenterPos, ControlOffset, CenterWidth, 1));
00043		VoicePackCombo.SetText(VoicePackText);
00044		VoicePackCombo.SetHelpText(VoicePackHelp);
00045		VoicePackCombo.SetFont(F_Normal);
00046		VoicePackCombo.SetEditable(False);
00047	
00048		ControlOffset += 25;
00049		SpectatorCheck = UWindowCheckbox(CreateControl(class'UWindowCheckbox', CenterPos, ControlOffset, CenterWidth, 1));
00050		SpectatorCheck.SetText(SpectatorText);
00051		SpectatorCheck.SetHelpText(SpectatorHelp);
00052		SpectatorCheck.SetFont(F_Normal);
00053		SpectatorCheck.Align = TA_Left;
00054	
00055	/*	ControlOffset += 25;
00056		CommanderCheck = UWindowCheckbox(CreateControl(class'UWindowCheckbox', CenterPos, ControlOffset, CenterWidth, 1));
00057		CommanderCheck.SetText(CommanderText);
00058		CommanderCheck.SetHelpText(CommanderHelp);
00059		CommanderCheck.SetFont(F_Normal);
00060		CommanderCheck.Align = TA_Left;*/
00061	
00062		ControlOffset += 25;
00063		StatsLabel = UMenuLabelControl(CreateControl(class'UMenuLabelControl', CenterPos, ControlOffset, CenterWidth, 1));
00064		StatsLabel.SetText(StatsText);
00065		StatsLabel.SetFont(F_Normal);
00066		StatsLabel.Align = TA_Left;
00067	
00068		StatsButton = UWindowSmallButton(CreateControl(class'UWindowSmallButton', CenterPos + CenterWidth - 48, ControlOffset, 48, 16));
00069		StatsButton.SetText(StatsButtonText);
00070		StatsButton.SetFont(F_Normal);
00071	}
00072	
00073	function LoadCurrent()
00074	{
00075		local string Voice, OverrideClassName;
00076		local class<PlayerPawn> OverrideClass;
00077		local string SN, FN;
00078	
00079		Voice = "";
00080		NameEdit.SetValue(GetPlayerOwner().PlayerReplicationInfo.PlayerName);
00081		TeamCombo.SetSelectedIndex(Max(TeamCombo.FindItemIndex2(string(GetPlayerOwner().PlayerReplicationInfo.Team)), 0));
00082		if(GetLevel().Game != None && GetLevel().Game.IsA('UTIntro') || GetPlayerOwner().IsA('Commander') || GetPlayerOwner().IsA('Spectator'))
00083		{
00084			SN = GetPlayerOwner().GetDefaultURL("Skin");
00085			FN = GetPlayerOwner().GetDefaultURL("Face");
00086			ClassCombo.SetSelectedIndex(Max(ClassCombo.FindItemIndex2(GetPlayerOwner().GetDefaultURL("Class"), True), 0));
00087			Voice = GetPlayerOwner().GetDefaultURL("Voice");
00088		}
00089		else
00090		{
00091			ClassCombo.SetSelectedIndex(Max(ClassCombo.FindItemIndex2(string(GetPlayerOwner().Class), True), 0));
00092			GetPlayerOwner().static.GetMultiSkin(GetPlayerOwner(), SN, FN);
00093		}
00094		SkinCombo.SetSelectedIndex(Max(SkinCombo.FindItemIndex2(SN, True), 0));
00095		FaceCombo.SetSelectedIndex(Max(FaceCombo.FindItemIndex2(FN, True), 0));
00096	
00097		if(Voice == "")
00098			Voice = string(GetPlayerOwner().PlayerReplicationInfo.VoiceType);
00099	
00100		IterateVoices();
00101		VoicePackCombo.SetSelectedIndex(Max(VoicePackCombo.FindItemIndex2(Voice, True), 0));
00102	
00103		OverrideClassName = GetPlayerOwner().GetDefaultURL("OverrideClass");
00104		if(OverrideClassName != "")
00105			OverrideClass = class<PlayerPawn>(DynamicLoadObject(OverrideClassName, class'Class'));
00106	
00107		SpectatorCheck.bChecked = (OverrideClass != None && ClassIsChildOf(OverrideClass, class'CHSpectator'));
00108	/*	CommanderCheck.bChecked = (OverrideClass != None && ClassIsChildOf(OverrideClass, class'Commander'));*/
00109	}
00110	
00111	function ClassChanged()
00112	{
00113		Super.ClassChanged();
00114	
00115		if(ClassIsChildOf(NewPlayerClass, class'TournamentPlayer'))
00116		{
00117			if(Initialized)
00118			{
00119				ClassChanging = True;
00120				IterateVoices();
00121				VoicePackCombo.SetSelectedIndex(Max(VoicePackCombo.FindItemIndex2(class<TournamentPlayer>(NewPlayerClass).default.VoiceType, True), 0));
00122				ClassChanging = False;
00123			}
00124			VoicePackCombo.ShowWindow();
00125		}
00126		else
00127		{
00128			VoicePackCombo.HideWindow();
00129		}
00130	}
00131	
00132	function IterateVoices()
00133	{
00134		local int NumVoices;
00135		local string NextVoice, NextDesc;
00136		local string VoicepackMetaClass;
00137		local bool OldInitialized;
00138	
00139		OldInitialized = Initialized;
00140		Initialized = False;
00141		VoicePackCombo.Clear();
00142		Initialized = OldInitialized;
00143	
00144		if(ClassIsChildOf(NewPlayerClass, class'TournamentPlayer'))
00145			VoicePackMetaClass = class<TournamentPlayer>(NewPlayerClass).default.VoicePackMetaClass;
00146		else
00147			VoicePackMetaClass = "Botpack.ChallengeVoicePack";
00148	
00149		// Load the base class into memory to prevent GetNextIntDesc crashing as the class isn't loadded.
00150		DynamicLoadObject(VoicePackMetaClass, class'Class');
00151	
00152		GetPlayerOwner().GetNextIntDesc(VoicePackMetaClass, 0, NextVoice, NextDesc);
00153		while( (NextVoice != "") && (NumVoices < 64) )
00154		{
00155			if(!(NextVoice ~= "Botpack.VoiceBoss") || class'Ladder'.Default.HasBeatenGame)
00156				VoicePackCombo.AddItem(NextDesc, NextVoice, 0);
00157	
00158			NumVoices++;
00159			GetPlayerOwner().GetNextIntDesc(VoicePackMetaClass, NumVoices, NextVoice, NextDesc);
00160		}
00161	
00162		VoicePackCombo.Sort();
00163	}
00164	
00165	function BeforePaint(Canvas C, float X, float Y)
00166	{
00167		local float W, H;
00168		local float XWidth, YHeight, XMod, YMod, XPos, YPos, YOffset, XL, YL;
00169		local int ControlWidth, ControlLeft, ControlRight;
00170		local int CenterWidth, CenterPos;
00171	
00172		W = Min(WinWidth, 220);
00173	
00174		ControlWidth = W/3;
00175		ControlLeft = (W/2 - ControlWidth)/2;
00176		ControlRight = W/2 + ControlLeft;
00177	
00178		CenterWidth = (W/7)*6;
00179		CenterPos = (W - CenterWidth)/2;
00180	
00181		W = Root.WinWidth / 4;
00182		H = W;
00183	
00184		if(W > 256 || H > 256)
00185		{
00186			W = 256;
00187			H = 256;
00188		}
00189	
00190		XMod = 4*W;
00191		YMod = 3*H;
00192	
00193	
00194		Super.BeforePaint(C, X, Y);
00195	
00196		VoicePackCombo.SetSize(CenterWidth, 1);
00197		VoicePackCombo.WinLeft = CenterPos;
00198		VoicePackCombo.EditBoxWidth = 105;
00199	
00200		SpectatorCheck.SetSize(CenterWidth, 1);
00201		SpectatorCheck.WinLeft = CenterPos;
00202	
00203	/*	CommanderCheck.SetSize(CenterWidth, 1);
00204		CommanderCheck.WinLeft = CenterPos;*/
00205	
00206		StatsLabel.SetSize(CenterWidth, 1);
00207		StatsLabel.WinLeft = CenterPos;
00208	
00209		StatsButton.AutoWidth(C);
00210		StatsButton.WinLeft = CenterPos + CenterWidth - 48;
00211	}
00212	
00213	function Notify(UWindowDialogControl C, byte E)
00214	{
00215		Super.Notify(C, E);
00216	
00217		switch(E)
00218		{
00219		case DE_Change:
00220			switch(C)
00221			{
00222			case VoicePackCombo:
00223				VoiceChanged();
00224				break;
00225			case SpectatorCheck:
00226				SpectatorChanged();
00227				break;
00228	/*		case CommanderCheck:
00229				CommanderChanged();
00230				break;*/
00231			}
00232			break;
00233		case DE_Click:
00234			switch(C)
00235			{
00236			case StatsButton:
00237				StatsPressed();
00238				break;
00239			}
00240			break;
00241	
00242		}
00243	}
00244	
00245	function StatsPressed()
00246	{
00247		Root.CreateWindow(class<UWindowWindow>(DynamicLoadObject("UTMenu.ngWorldSecretWindow", class'Class')), 100, 100, 200, 200, Root, True);
00248	}
00249	
00250	function SpectatorChanged()
00251	{
00252	/*	CommanderCheck.bChecked = False;*/
00253	
00254		if(SpectatorCheck.bChecked)
00255			GetPlayerOwner().UpdateURL("OverrideClass", "Botpack.CHSpectator", True);
00256		else
00257			GetPlayerOwner().UpdateURL("OverrideClass", "", True);
00258	}
00259	
00260	/*function CommanderChanged()
00261	{
00262		SpectatorCheck.bChecked = False;
00263	
00264		if(CommanderCheck.bChecked)
00265			GetPlayerOwner().UpdateURL("OverrideClass", "Botpack.Commander", True);
00266		else
00267			GetPlayerOwner().UpdateURL("OverrideClass", "", True);
00268	}*/
00269	
00270	simulated function VoiceChanged()
00271	{
00272		local class<ChallengeVoicePack> VoicePackClass;
00273		local ChallengeVoicePack V;
00274	
00275		if(Initialized)
00276		{
00277			VoicePackClass = class<ChallengeVoicePack>(DynamicLoadObject(VoicePackCombo.GetValue2(), class'Class'));
00278			if(!ClassChanging)
00279			{
00280				V = GetPlayerOwner().spawn(VoicePackClass,GetPlayerOwner(),,GetPlayerOwner().Location);
00281				V.ClientInitialize(GetPlayerOwner().PlayerReplicationInfo,GetPlayerOwner().PlayerReplicationInfo,'ACK', Rand(VoicePackClass.Default.NumAcks));
00282			}
00283			GetPlayerOwner().UpdateURL("Voice", VoicePackCombo.GetValue2(), True);
00284	
00285			if( ClassCombo.GetValue2() ~= string(GetPlayerOwner().Class) && GetPlayerOwner().IsA('TournamentPlayer') )
00286				TournamentPlayer(GetPlayerOwner()).SetVoice(VoicePackClass);
00287		}
00288	}
00289	
00290	function LoadClasses()
00291	{
00292		local int NumPlayerClasses;
00293		local string NextPlayer, NextDesc;
00294	
00295		GetPlayerOwner().GetNextIntDesc("TournamentPlayer", 0, NextPlayer, NextDesc);
00296		while( (NextPlayer != "") && (NumPlayerClasses < 64) )
00297		{
00298			if (!(NextPlayer ~= "Botpack.TBoss") || class'Ladder'.Default.HasBeatenGame)
00299				ClassCombo.AddItem(NextDesc, NextPlayer, 0);
00300	
00301			NumPlayerClasses++;
00302			GetPlayerOwner().GetNextIntDesc("TournamentPlayer", NumPlayerClasses, NextPlayer, NextDesc);
00303		}
00304	
00305		ClassCombo.Sort();
00306	}
00307	
00308	defaultproperties
00309	{
00310	     VoicePackText="Voice"
00311	     VoicePackHelp="Choose a voice for your player's taunts and commands."
00312	     SpectatorText="Play as Spectator"
00313	     SpectatorHelp="Check this checkbox to watch the action in the game as a spectator."
00314	     StatsText="ngWorldStats Password:"
00315	     StatsButtonText="Change"
00316	}

End Source Code