## XIDInterf
Class XIIIMenuBotsSetupClient

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

    Core.Object
       |
       +--GUI.GUI
          |
          +--GUI.GUIComponent
             |
             +--GUI.GUIMultiComponent
                |
                +--GUI.GUIPage
                   |
                   +--XIDInterf.XIIIWindow
                      |
                      +--XIDInterf.XIIIWindowMainMenu
                         |
                         +--XIDInterf.XIIIMenuMultiBase
                            |
                            +--XIDInterf.XIIIMenuBotsSetupClient

Direct Known Subclasses:None

class XIIIMenuBotsSetupClient
extends XIDInterf.XIIIMenuMultiBase

Variables
`RedTeam,` | `BlueTeam`
`array` | `BotSkills`
`array` | `BotTeams`
`XIIIValueControl` | `BotsCombo`
`Config1Text,` | `Config2Text`
`FriendlyFire,` | `DefaultConfig`
`XIIIComboControl` | `DefaultConfigButton`
`class` | `GameClass`
`int` | `GameTypeIndex`
`URL,` | `Map`
`Error5Text,` | `MessageText`
`int` | `OnCombo`
`bInitialized,` | `bTeamGame`
`sBackground,` | `sHighlight`
`tBackground,` | `tHighlight`

Function Summary
`void` | `AfterCreate()`
`void` | `Created()`
`bool` | `InternalOnKeyEvent(out byte, out byte, float delta)`
`void` | `Paint(Canvas C, float X, float Y)`
`void` | `ShowWindow()`

Source Code

    00001	class XIIIMenuBotsSetupClient extends XIIIMenuMultiBase;
    00002
    00003	var int OnCombo;
    00004
    00005	var class<GameInfo> GameClass;
    00006	var array<XIIIComboControl> BotSkills;
    00007	var array<XIIICheckBoxControl> BotTeams;
    00008	var XIIIValueControl BotsCombo;
    00009	var XIIIComboControl DefaultConfigButton;
    00010
    00011	var localized string NbBotText, BotText, SkillText, TeamText, SkillsText[4], RedTeam, BlueTeam;
    00012	var localized string Error1Text, Error2Text, Error3Text, Error4Text, Error5Text, MessageText;
    00013	var localized string DefaultConfigText, Config1Text, Config2Text;
    00014	var string URL, Map;
    00015
    00016	VAR int GameTypeIndex;
    00017	var int IPC, N, MaxBots, FragLimit, TimeLimit, BotNumber, TeamBot[7], NivBot[7], PC[4], PT[4], FriendlyFire, DefaultConfig;
    00018
    00019	var string sBackground, sHighlight;
    00020	var texture tBackground, tHighlight;
    00021
    00022	var bool bInitialized, bTeamGame;
    00023
    00024
    00025	function Created()
    00026	{
    00027	    local int i, j;
    00028
    00029		Super.Created();
    00030
    00031		tBackGround = texture(DynamicLoadObject(sBackGround, class'Texture'));
    00032		tHighlight = texture(DynamicLoadObject(sHighlight, class'Texture'));
    00033
    00034		// MLK: Test weither the selected map can support additionnal bots
    00035		if (MaxBots > 0)
    00036	    {
    00037	        BotsCombo = XIIIValueControl(CreateControl(class'XIIIValueControl', 194, 35*fScaleTo, 288, 35));
    00038	        BotsCombo.Text = NbBotText;
    00039			BotsCombo.SetRange(0,MaxBots);
    00040	        BotsCombo.SetValue(BotNumber);
    00041	        Controls[0] = BotsCombo;
    00042
    00043			for (i=0; i<MaxBots; i++)
    00044	        {
    00045				BotSkills[i] = XIIIComboControl(CreateControl(class'XIIIComboControl', 40, (85 + i*50)*fScaleTo, 280, 25));
    00046	            BotSkills[i].Text = BotText$i+1@":"@SkillText;
    00047	            BotSkills[i].bArrows = true;
    00048				BotSkills[i].bCalculateSize = false;
    00049				BotSkills[i].FirstBoxWidth = 170;
    00050	            for (j=0; j<4; j++)
    00051	                BotSkills[i].AddItem(SkillsText[j]);
    00052
    00053				BotSkills[i].SetSelectedIndex(NivBot[i]);
    00054
    00055	            Controls[i*2 + 1] = BotSkills[i];
    00056
    00057	            BotTeams[i] = XIIICheckboxControl(CreateControl(class'XIIICheckboxControl', 330, (95 + i*50)*fScaleTo, 280, 25));
    00058				BotTeams[i].Text = BotText$i+1@":"@TeamText;
    00059	            BotTeams[i].sYes = BlueTeam;
    00060	            BotTeams[i].sNo = RedTeam;
    00061				BotTeams[i].bWhiteColorOnlyWhenFocused = true;
    00062	            Controls[i*2 + 2] = BotTeams[i];
    00063				XIIICheckBoxControl(Controls[i*2 + 2]).bChecked = bool(TeamBot[i]);
    00064
    00065				// no team in deathmatch, kill the mouette and mario modes
    00066				if (( GameTypeIndex == DeathmatchIndex ) || ( GameTypeIndex == TheHuntIndex ) || ( GameTypeIndex == PowerUpIndex ))
    00067	            {
    00068					BotTeams[i].bNeverFocus = true;
    00069	                bTeamGame = false;
    00070	            }
    00071	            else
    00072					bTeamGame = true;
    00073	        }
    00074
    00075			// default mode : use map default bots
    00076			DefaultConfigButton = XIIIComboControl(CreateControl(class'XIIIComboControl', 80, 200*fScaleTo, 480, 35));
    00077			DefaultConfigButton.Text = DefaultConfigText;
    00078			DefaultConfigButton.bArrows = true;
    00079			DefaultConfigButton.AddItem(Config1Text);
    00080			DefaultConfigButton.AddItem(Config2Text);
    00081			DefaultConfigButton.SetSelectedIndex(DefaultConfig);
    00082			Controls[MaxBots*2 + 1] = DefaultConfigButton;
    00083
    00084	        AfterCreate();
    00085
    00086	        bInitialized = true;
    00087		}
    00088	}
    00089
    00090	function AfterCreate()
    00091	{
    00092	    local int i, j;
    00093
    00094	    if (BotNumber < 1)
    00095	    {
    00096	        for (i=0; i<MaxBots; i++)
    00097	        {
    00098	            BotSkills[i].bNeverFocus = true;
    00099				BotSkills[i].bVisible = false;
    00100	            BotTeams[i].bNeverFocus = true;
    00101				BotTeams[i].bVisible = false;
    00102	        }
    00103			DefaultConfigButton.bVisible = true;
    00104			DefaultConfigButton.bNeverFocus = false;
    00105	    }
    00106	    else
    00107		{
    00108	        for (i=0; i<BotNumber; i++)
    00109	        {
    00110				BotSkills[i].bNeverFocus = false;
    00111				BotSkills[i].bVisible = true;
    00112	            if (!bTeamGame)
    00113				{
    00114					BotTeams[i].bNeverFocus = true;
    00115					BotTeams[i].bVisible = false;
    00116				}
    00117	            else
    00118				{
    00119	                BotTeams[i].bNeverFocus = false;
    00120					BotTeams[i].bVisible = true;
    00121				}
    00122	        }
    00123	        for (i=BotNumber; i<MaxBots; i++)
    00124	        {
    00125				BotSkills[i].bNeverFocus = true;
    00126				BotSkills[i].bVisible = false;
    00127	            BotTeams[i].bNeverFocus = true;
    00128				BotTeams[i].bVisible = false;
    00129	        }
    00130			DefaultConfigButton.bVisible = false;
    00131			DefaultConfigButton.bNeverFocus = true;
    00132	    }
    00133
    00134		if ( BotsCombo.Value==0 )
    00135			BotsCombo.sValue="-";
    00136
    00137	}
    00138
    00139
    00140	event HandleParameters(string Param1, string Param2)
    00141	{
    00142		if ( Param1!="" )
    00143		{
    00144			URL = Param1;
    00145			log("Param1="$URL);
    00146			Map = localParseOption ( URL, "Map", "");
    00147			GameTypeIndex = int(localParseOption ( URL, "GameTypeIndex", "0"));
    00148			IPC = int( localParseOption( URL,"IP", "0") );
    00149			N = int( localParseOption( URL,"NP", "0") );
    00150			FriendlyFire = int( localParseOption( URL,"FF", "0") );
    00151			FragLimit = int( localParseOption( URL,"FR", "0") );
    00152			TimeLimit = int( localParseOption( URL,"TI", "0") );
    00153			DefaultConfig = int( localParseOption( URL,"DC", "0") );
    00154			BotNumber = int( localParseOption( URL,"NBots", "0") );
    00155			TeamBot[0] = int( localParseOption( URL,"TB0", "1") );
    00156			NivBot[0] = int( localParseOption( URL,"NB0", "1") );
    00157			TeamBot[1] = int( localParseOption( URL,"TB1", "0") );
    00158			NivBot[1] = int( localParseOption( URL,"NB1", "2") );
    00159			TeamBot[2] = int( localParseOption( URL,"TB2", "1") );
    00160			NivBot[2] = int( localParseOption( URL,"NB2", "2") );
    00161			TeamBot[3] = int( localParseOption( URL,"TB3", "0") );
    00162			NivBot[3] = int( localParseOption( URL,"NB3", "0") );
    00163			TeamBot[4] = int( localParseOption( URL,"TB4", "1") );
    00164			NivBot[4] = int( localParseOption( URL,"NB4", "0") );
    00165			TeamBot[5] = int( localParseOption( URL,"TB5", "0") );
    00166			NivBot[5] = int( localParseOption( URL,"NB5", "3") );
    00167			TeamBot[6] = int( localParseOption( URL,"TB6", "1") );
    00168			NivBot[6] = int( localParseOption( URL,"NB6", "3") );
    00169			PC[0] = int( localParseOption( URL,"PC0", "0") );
    00170			PC[1] = int( localParseOption( URL,"PC1", "0") );
    00171			PC[2] = int( localParseOption( URL,"PC2", "1") );
    00172			PC[3] = int( localParseOption( URL,"PC3", "1") );
    00173			PT[0] = int( localParseOption( URL,"PT0", "0") );
    00174			PT[1] = int( localParseOption( URL,"PT1", "1") );
    00175			PT[2] = int( localParseOption( URL,"PT2", "0") );
    00176			PT[3] = int( localParseOption( URL,"PT3", "1") );
    00177
    00178			MaxBots = IPC - N;
    00179			//log(self@"--->"@Map@GameType@IPC@N@FragLimit@TimeLimit@BotNumber@MaxBots);
    00180			//log(self@"--->"@NivBot[0]@NivBot[1]@NivBot[2]@NivBot[3]@NivBot[4]@NivBot[5]@NivBot[6]);
    00181		}
    00182	}
    00183
    00184
    00185	function ShowWindow()
    00186	{
    00187	     Super.ShowWindow();
    00188	     bShowBCK = true;
    00189	     bShowACC = true;
    00190	}
    00191
    00192
    00193	function Paint(Canvas C, float X, float Y)
    00194	{
    00195
    00196
    00197	   local float W, H;
    00198
    00199	   local array<string> MsgArray;
    00200	   local int v;
    00201	   local int Length;
    00202	   local int TextWith;
    00203
    00204
    00205	     Super.Paint(C, X, Y);
    00206
    00207		DrawStretchedTexture(C, 28*fRatioX, 28*fScaleTo*fRatioY, 584*fRatioX, 406*fRatioY*fScaleTo, myRoot.tFondNoir);
    00208		DrawStretchedTexture(C,  30*fRatioX,  30*fScaleTo*fRatioY, 580*fRatioX, 402*fScaleTo*fRatioY, tBackGround);
    00209
    00210		if ( maxBots > 0 )
    00211		{
    00212			if ( BotNumber > 0 )
    00213			{
    00214				OnMenu = FindComponentIndex(FocusedControl);
    00215				C.Style = 5;
    00216				C.DrawColor.A = 128;
    00217				if ( OnMenu == 0 )
    00218				{
    00219					DrawStretchedTexture(C, 80*fRatioX, 35*fScaleTo*fRatioY, 480*fRatioX, 35*fScaleTo*fRatioY, tHighlight);
    00220				}
    00221				else
    00222				{
    00223					if ( float(OnMenu)/2 != int(float(OnMenu/2)) )
    00224					{
    00225						DrawStretchedTexture(C, 20*fRatioX, (50 + 25*OnMenu)*fScaleTo*fRatioY, 300*fRatioX, 45*fScaleTo*fRatioY, tHighlight);
    00226					}
    00227					else
    00228					{
    00229						DrawStretchedTexture(C, 320*fRatioX, (35 + 25*OnMenu)*fScaleTo*fRatioY, 320*fRatioX, 45*fScaleTo*fRatioY, tHighlight);
    00230					}
    00231				}
    00232				C.Style = 1;
    00233				C.DrawColor.A = 255;
    00234			}
    00235			else
    00236			{
    00237				OnMenu = FindComponentIndex(FocusedControl);
    00238				C.Style = 5;
    00239				C.DrawColor.A = 128;
    00240				if ( OnMenu == 0 )
    00241				{
    00242					DrawStretchedTexture(C, 80*fRatioX, 35*fScaleTo*fRatioY, 480*fRatioX, 35*fScaleTo*fRatioY, tHighlight);
    00243				}
    00244				else
    00245
{ 00246 if ( OnMenu == (Maxbots + 1) ) 00247 { 00248 DrawStretchedTexture(C, 80*fRatioX, 200*fScaleTo*fRatioY, 480*fRatioX, 35*fScaleTo*fRatioY, tHighlight); 00249 } 00250 } 00251 C.Style = 1; 00252 C.DrawColor.A = 255; 00253 } 00254 } 00255 else 00256 { 00257 if (MaxBots < 1) 00258 { 00259 TextWith = 400; 00260 //C.Font = font'XIIIFonts.XIIIConsoleFont'; 00261 //C.DrawColor = BlackColor; 00262 C.WrapStringToArray(MessageText, MsgArray, TextWith, "|"); 00263 Length = MsgArray.Length; 00264 if (Length > 1) 00265 { 00266 for(v=0;v<Length;v++) 00267 { 00268 C.TextSize(MsgArray[v], W, H); 00269 C.SetPos(120, 220 + (H*v*fRatioY)); 00270 C.DrawText(MsgArray[v], false); 00271 } 00272 } 00273 00274 //C.DrawColor = WhiteColor; 00275 //C.SetPos(120*fRatioX, 180*fRatioY); 00276 //C.DrawText(Caps(Error1Text), false); 00277 //C.SetPos(120*fRatioX, 210*fRatioY); 00278 //C.DrawText(Caps(Error2Text), false); 00279 //C.SetPos(120*fRatioX, 240*fRatioY); 00280 //C.DrawText(Caps(Error3Text), false); 00281 } 00282 /* else 00283 { 00284 if (BotNumber == -1) 00285 { 00286 C.SetPos(125*fRatioX, 210*fRatioY); C.DrawText(Caps(Error4Text), false); 00287 } 00288 else 00289 { 00290 if (BotNumber == 0) 00291 { 00292 C.SetPos(125*fRatioX, 210*fRatioY); C.DrawText(Caps(Error5Text), false); 00293 } 00294 } 00295 }*/ 00296 } 00297 } 00298 00299 00300 function bool InternalOnKeyEvent(out byte Key, out byte State, float delta) 00301 { 00302 if (State==1)// IST_Press // to avoid auto-repeat 00303 { 00304 if (Key==0x0D/*IK_Enter*/) 00305 { 00306 URL = 00307 "?Map="$Map$ 00308 "?IP="$IPC$ 00309 "?NP="$N$ 00310 "?FF="$FriendlyFire$ 00311 "?FR="$FragLimit$ 00312 "?TI="$TimeLimit$ 00313 "?NBots="$BotNumber$ 00314 "?DC="$DefaultConfig$ 00315 "?TB0="$TeamBot[0]$ 00316 "?NB0="$NivBot[0]$ 00317 "?TB1="$TeamBot[1]$ 00318 "?NB1="$NivBot[1]$ 00319 "?TB2="$TeamBot[2]$ 00320 "?NB2="$NivBot[2]$ 00321 "?TB3="$TeamBot[3]$ 00322 "?NB3="$NivBot[3]$ 00323 "?TB4="$TeamBot[4]$ 00324 "?NB4="$NivBot[4]$ 00325 "?TB5="$TeamBot[5]$ 00326 "?NB5="$NivBot[5]$ 00327 "?TB6="$TeamBot[6]$ 00328 "?NB6="$NivBot[6]$ 00329 "?PC0="$PC[0]$ 00330 "?PC1="$PC[1]$ 00331 "?PC2="$PC[2]$ 00332 "?PC3="$PC[3]$ 00333 "?PT0="$PT[0]$ 00334 "?PT1="$PT[1]$ 00335 "?PT2="$PT[2]$ 00336 "?PT3="$PT[3]; 00337 00338 //log(URL); 00339 00340 myRoot.CloseMenu(true, URL); 00341 return true; 00342 } 00343 if ((Key==0x08/*IK_Backspace*/)|| (Key==0x1B)) 00344 { 00345 myRoot.CloseMenu(true, URL); 00346 return true; 00347 } 00348 if (MaxBots > 0) 00349 { 00350 if (Key==0x26/*IK_Up*/) 00351 { 00352 PrevControl(FocusedControl); 00353 return true; 00354 } 00355 if (Key==0x28/*IK_Down*/) 00356 { 00357 NextControl(FocusedControl); 00358 return true; 00359 } 00360 if ((Key==0x25) || (Key==0x27)) 00361 { 00362 OnMenu = FindComponentIndex(FocusedControl); 00363 if (FocusedControl == Controls[0]) 00364 { 00365 if (Key==0x25) BotNumber--; 00366 if (Key==0x27) BotNumber++; 00367 BotNumber = Clamp(BotNumber,0,MaxBots); 00368 BotsCombo.SetValue(BotNumber); 00369 AfterCreate(); 00370 return true; 00371 } 00372 if (FocusedControl == Controls[MaxBots*2 + 1]) 00373 { 00374 if (Key==0x25) DefaultConfig--; 00375 if (Key==0x27) DefaultConfig++; 00376 DefaultConfig = Clamp(DefaultConfig,0,1); 00377 DefaultConfigButton.SetSelectedIndex(DefaultConfig); 00378 return true; 00379 } 00380 if (OnMenu%2 == 1) 00381 { 00382 OnCombo = XIIIComboControl(FocusedControl).GetSelectedIndex(); 00383 if (Key==0x25) OnCombo--; 00384 if (Key==0x27) OnCombo++; 00385 OnCombo = Clamp(OnCombo,0,3); 00386 XIIIComboControl(FocusedControl).SetSelectedIndex(OnCombo); 00387 NivBot[int( 0.5*( OnMenu - 1 ) )] = OnCombo; 00388 } 00389 else if (OnMenu%2 == 0) 00390 { 00391 if (Key==0x25) XIIICheckBoxControl(FocusedControl).bChecked = true; 00392 else if (Key==0x27) XIIICheckBoxControl(FocusedControl).bChecked = false; 00393 TeamBot[int( 0.5*( OnMenu - 2 ) )] = int(XIIICheckBoxControl(FocusedControl).bChecked); 00394 } 00395 return true; 00396 } 00397 } 00398 } 00399 return super.InternalOnKeyEvent(Key, state, delta); 00400 } 00401 00402 00403 00404 00405 defaultproperties 00406 { 00407 NbBotText="Bot Number" 00408 BotText="Bot" 00409 SkillText="Skill" 00410 TeamText="Team" 00411 SkillsText(0)="Easy" 00412 SkillsText(1)="Medium" 00413 SkillsText(2)="Hard" 00414 SkillsText(3)="Insane" 00415 RedTeam="Red" 00416 BlueTeam="Blue" 00417 Error1Text="This Map can't support more than the actual number" 00418 Error2Text="of players. Please change your number of players" 00419 Error3Text="setting to be able to play current map with bots" 00420 Error4Text="Game will use map default bots" 00421 Error5Text="Bots are disabled for the current map" 00422 MessageText="This Map can't support more than the actual number of players. Please change your number of players setting to be able to play current map with bots" 00423 DefaultConfigText="Default Config" 00424 Config1Text="Use Map Default Bots" 00425 Config2Text="Disable All Bots" 00426 MaxBots=4 00427 sBackground="XIIIMenuStart.vignette_fond" 00428 sHighlight="XIIIMenuStart.barreselectmenuoptadv" 00429 bUseDefaultBackground=False 00430 }

End Source Code