XIDInterf
Class XIIIMenuLiveOptimatchResultWindow

source: C:\XIII\XIDInterf\Classes\XIIIMenuLiveOptimatchResultWindow.uc
Core.Object
   |
   +--GUI.GUI
      |
      +--GUI.GUIComponent
         |
         +--GUI.GUIMultiComponent
            |
            +--GUI.GUIPage
               |
               +--XIDInterf.XIIIWindow
                  |
                  +--XIDInterf.XIIILiveWindow
                     |
                     +--XIDInterf.XIIIMenuLiveOptimatchResultWindow
Direct Known Subclasses:None

class XIIIMenuLiveOptimatchResultWindow
extends XIDInterf.XIIILiveWindow


Variables
 string AutoLoginName
 int BackFromJoin
 bool BackFromJoinNotNow
 bool ConnectingToGame
 XIIIGUIButton CycleLevelsButton
 string DutchString
 string EnglishString
 XIIIGUIButton FragLimitButton
 string FrenchString
 XIIIGUIButton FriendlyFireButton
 XIIIGUIButton GameTypeButton
 string GameTypeStrings[6]
 string GermanString
 string ItalianString
 string LabelNames[8]
 GUILabel Labels[8]
 XIIIGUIButton LanguageButton
 XIIIGUIButton MapNameButton
 XIIIGUIButton PlayerCountButton
 bool ProbeRunning
 Texture QoSIcons[4]
 string SpanishString
 string SwedishString
 XIIIGUIButton TimeLimitButton
 bool UpdateMe
 string YesString,NoString,AnyString
 string areYouSureToJoinRed
 string failedToJoinString
 XIIIGUIMultiListBox listboxMulti
 string noGamesFoundString
 TitleText, noOptimatchResultString
 int oldsel
 string probeFailedString
 int searchFriendlyFire
 XboxLiveManager.eGameType searchGameType
 XboxLiveManager.eLanguage searchLanguage
 string searchMap
 int sessionsel
 float starttime
 XIIILiveMsgBox waitbox


Function Summary
 void Created()
 string GetPageParameters()
     
// if subclassed, this parent function must always be called first
 void InitComponent(GUIController MyController, GUIComponent MyOwner)
 bool InternalOnClick(GUIComponent Sender)
     
// Called when a button is clicked
 bool InternalOnKeyEvent(out byte, out byte, float delta)
 void MsgBoxBtnClicked(byte bButton)
 void MsgBoxBtnClickedForRed(byte bButton)
 void Paint(Canvas C, float X, float Y)
 void Process()
 void ProcessConnect()
 void ResetButtons()
 void SetPageParameters(string PageParameters)
     
// if GetPageParameters() is subclassed, you'd better have this one too !
 void ShowWindow()
 void StartGameMsgBox(BYTE button)
 void WaitBoxBtnClicked(byte bButton)



Source Code


00001	class XIIIMenuLiveOptimatchResultWindow extends XIIILiveWindow;
00002	
00003	//var GUIListBox listbox;
00004	var XIIIGUIMultiListBox listboxMulti;
00005	var localized string TitleText, noOptimatchResultString;
00006	
00007	var bool UpdateMe;
00008	var bool ConnectingToGame;
00009	
00010	var XIIIGUIButton GameTypeButton;
00011	var XIIIGUIButton MapNameButton;
00012	var XIIIGUIButton FragLimitButton;
00013	var XIIIGUIButton TimeLimitButton;
00014	var XIIIGUIButton FriendlyFireButton;
00015	var XIIIGUIButton CycleLevelsButton;
00016	var XIIIGUIButton LanguageButton;
00017	var XIIIGUIButton PlayerCountButton;
00018	
00019	var XIIILiveMsgBox waitbox;
00020	
00021	var texture QoSIcons[4];
00022	
00023	var bool ProbeRunning;
00024	
00025	var localized string LabelNames[8];
00026	var GUILabel Labels[8];
00027	
00028	var int oldsel;
00029	var float starttime;
00030	
00031	var localized string EnglishString;
00032	var localized string FrenchString;
00033	var localized string GermanString;
00034	var localized string SpanishString;
00035	var localized string SwedishString;
00036	var localized string DutchString;
00037	var localized string ItalianString;
00038	
00039	var localized string probeFailedString;
00040	
00041	var localized string GameTypeStrings[6];
00042	
00043	var localized string YesString,NoString,AnyString;
00044	
00045	var localized string failedToJoinString;
00046	var localized string noGamesFoundString;
00047	
00048	var localized string areYouSureToJoinRed;
00049	var int sessionsel;
00050	
00051	var int BackFromJoin;
00052	var bool BackFromJoinNotNow;
00053	var string AutoLoginName;
00054	
00055	var XboxLiveManager.eGameType 	searchGameType;
00056	var string 			searchMap;
00057	var int     			searchFriendlyFire;
00058	var XboxLiveManager.eLanguage	searchLanguage;
00059	
00060	function String GetLanguageString(XboxLiveManager.eLanguage language)
00061	{
00062	  switch (language)
00063	  {
00064	    case LANG_All:
00065	    return AnyString;
00066	    case LANG_EnglishOnly:
00067	    return EnglishString;
00068	    case LANG_FrenchOnly:
00069	    return FrenchString;
00070	    case LANG_GermanOnly:
00071	    return GermanString;
00072	    case LANG_SpanishOnly:
00073	    return SpanishString;
00074	    case LANG_SwedishOnly:
00075	    return SwedishString;
00076	    case LANG_DutchOnly:
00077	    return DutchString;
00078	    case LANG_ItalianOnly:
00079	    return ItalianString;
00080	  }
00081	  return AnyString;
00082	}
00083	
00084	function string GetRealGameTypeString(XboxLiveManager.eGameType gameType)
00085	{
00086	  switch (gameType)
00087	  {
00088	    case GT_DM:
00089	      return "XIIIMP.XIIIMPGameInfo";
00090	    case GT_TeamDM:
00091	      return "XIIIMP.XIIIMPTeamGameInfo";
00092	    case GT_CTF:
00093	      return "XIIIMP.XIIIMPCTFGameInfo";
00094	    case GT_Sabotage:
00095	      return "XIIIMP.XIIIMPBombGame";
00096	    case GT_Duel:
00097	      return "XIIIMP.XIIIRocketArena";
00098	  }
00099	
00100	  return "";
00101	}
00102	
00103	function String GetGameTypeString(XboxLiveManager.eGameType gametype)
00104	{
00105	  switch (gametype)
00106	  {
00107	    case GT_DM:
00108	      return GameTypeStrings[0];
00109	    case GT_TeamDM:
00110	      return GameTypeStrings[1];
00111	    case GT_CTF:
00112	      return GameTypeStrings[2];
00113	    case GT_Duel:
00114	      return GameTypeStrings[3];
00115	    case GT_Sabotage:
00116	      return GameTypeStrings[4];
00117	  }
00118	  return GameTypeStrings[5];
00119	}
00120	
00121	function ResetButtons()
00122	{
00123	  local int sel;
00124	
00125	  local XboxLiveManager.eGameType gametype;
00126	  local string mapname;
00127	  local int fraglimit;
00128	  local int timelimit;
00129	  local XboxLiveManager.eLanguage language;
00130	  local XboxLiveManager.eSkill minskill;
00131	  local XboxLiveManager.eSkill maxskill;
00132	  local int playercount;
00133	  local bool friendlyfire;
00134	  local bool cyclelevels;
00135	  local int maxplayers;
00136	
00137	  sel = listboxMulti.list.Index;
00138	  if (sel >= 0 && sel < listboxMulti.list.Elements.length)
00139	  {
00140	    gametype    = xboxlive.OptimatchGetGameType(sel);
00141	    mapname     = xboxlive.OptimatchGetMapName(sel);
00142	    fraglimit   = xboxlive.OptimatchGetFragLimit(sel);
00143	    timelimit   = xboxlive.OptimatchGetTimeLimit(sel);
00144	    language    = xboxlive.OptimatchGetLanguage(sel);
00145	    minskill    = xboxlive.OptimatchGetMinSkill(sel);
00146	    maxskill    = xboxlive.OptimatchGetMaxSkill(sel);
00147	    playercount = xboxlive.OptimatchGetPlayerCount(sel);
00148	    friendlyfire= xboxlive.OptimatchGetFriendlyFire(sel);
00149	    cyclelevels = xboxlive.OptimatchGetCycleLevels(sel);
00150	    maxplayers  = xboxlive.OptimatchGetTotalPublicSlots(sel) + xboxlive.OptimatchGetTotalPrivateSlots(sel);
00151	
00152	    GameTypeButton.Caption      = GetGameTypeString(gametype);
00153	    MapNameButton.Caption       = xboxlive.GetNiceName(mapname);
00154	    FragLimitButton.Caption     = ""$fraglimit;
00155	
00156	    if (gametype == GT_Duel)
00157	      TimeLimitButton.Caption     = ""$timelimit$" sec";
00158	    else
00159	      TimeLimitButton.Caption     = ""$timelimit;
00160	    if (friendlyfire)
00161	      FriendlyFireButton.Caption  = YesString;
00162	    else
00163	      FriendlyFireButton.Caption  = NoString;
00164	    //if (cyclelevels)
00165	    //  CycleLevelsButton.Caption  = YesString;
00166	    //else
00167	    //  CycleLevelsButton.Caption  = NoString;
00168	    LanguageButton.Caption      = GetLanguageString(language);
00169	    PlayerCountButton.Caption   = ""$playercount$"/"$maxplayers;
00170	  }
00171	  else
00172	  {
00173	    GameTypeButton.Caption      = "";
00174	    MapNameButton.Caption       = "";
00175	    FragLimitButton.Caption     = "";
00176	    TimeLimitButton.Caption     = "";
00177	    FriendlyFireButton.Caption  = "";
00178	    //CycleLevelsButton.Caption   = "";
00179	    LanguageButton.Caption      = "";
00180	    PlayerCountButton.Caption   = "";
00181	  }
00182	}
00183	
00184	function Created()
00185	{
00186	  local int i;
00187	  local int msg;
00188	
00189	  Super.Created();
00190	  GameTypeButton        = XIIIGUIButton(CreateControl(class'XIIIGUIButton', 450-10,       100,    150,  30));
00191	  MapNameButton         = XIIIGUIButton(CreateControl(class'XIIIGUIButton', 450-10,       135,    150,  30));
00192	  PlayerCountButton     = XIIIGUIButton(CreateControl(class'XIIIGUIButton', 500-10-12.5,  170,    75,   30));
00193	  FriendlyFireButton    = XIIIGUIButton(CreateControl(class'XIIIGUIButton', 500-10,       204,    50,   30));
00194	  //CycleLevelsButton     = XIIIGUIButton(CreateControl(class'XIIIGUIButton', 500-10,       240,    50,   30));
00195	  LanguageButton        = XIIIGUIButton(CreateControl(class'XIIIGUIButton', 450-10,       240,    150,  30));
00196	  FragLimitButton       = XIIIGUIButton(CreateControl(class'XIIIGUIButton', 500-10-12.5,  275,    75,   30));
00197	  TimeLimitButton       = XIIIGUIButton(CreateControl(class'XIIIGUIButton', 500-10-12.5,  310,    75,   30));
00198	
00199	
00200	  QoSIcons[0]=texture'XIIIXboxPacket.QoS1';
00201	  QoSIcons[1]=texture'XIIIXboxPacket.QoS2';
00202	  QoSIcons[2]=texture'XIIIXboxPacket.QoS3';
00203	
00204	
00205	  //ResetButtons();
00206	
00207	  Controls[1]=GameTypeButton;
00208	  Controls[2]=MapNameButton;
00209	  Controls[3]=PlayerCountButton;
00210	  Controls[4]=FriendlyFireButton;
00211	  //Controls[5]=CycleLevelsButton;
00212	  Controls[5]=LanguageButton;
00213	  Controls[6]=FragLimitButton;
00214	  Controls[7]=TimeLimitButton;
00215	  for (i=1; i<=7; i++)
00216	  {
00217	    Controls[i].StyleName = "SquareButton";
00218	    Controls[i].bNeverFocus = true;
00219	    Labels[i-1] = GUILabel(CreateControl(class'GUILabel', 300, 100+35*(i-1), 150, 26));
00220	    if (i-1>=4)
00221	    	Labels[i-1].caption = LabelNames[i];
00222	    else
00223	    Labels[i-1].caption = LabelNames[i-1];
00224	    Labels[i-1].StyleName="LabelWhite";
00225	    Labels[i-1].TextColor.R=255;
00226	    Labels[i-1].TextColor.G=255;
00227	    Labels[i-1].TextColor.B=255;
00228	    controls[8+i-1] = Labels[i-1];
00229	  }
00230	}
00231	
00232	function InitComponent(GUIController MyController,GUIComponent MyOwner)
00233	{
00234	  Super.InitComponent(MyController, MyOwner);
00235	     listboxMulti = XIIIGUIMultiListBox(Controls[0]);
00236	  if (xboxlive == none)
00237	    xboxlive=New Class'XboxLiveManager';
00238		OnClick = InternalOnClick;
00239	  listboxMulti.bVisibleWhenEmpty = true;
00240	  updateMe = true;
00241	
00242	
00243	  listboxMulti.SetNumberOfColumns(3);
00244	  listboxMulti.SetColumnOffset(0, 0);
00245	  listboxMulti.SetColumnOffset(1, 150);
00246	  listboxMulti.SetColumnOffset(2, 205);
00247	
00248	  if (xboxlive.IsLoggedIn(xboxlive.GetCurrentUser()))
00249	  {
00250	    Controller.OpenMenu("XIDInterf.XIIILiveMsgBox",false);
00251	    waitbox = XIIILiveMsgBox(myRoot.ActivePage);
00252	    waitbox.ShowWorking=true;
00253	    waitbox.SetupQuestion(pleaseWaitString, QBTN_Cancel, QBTN_Cancel, "");
00254	    waitbox.InitBox(160, 130, 16, 16, 320, 190);
00255	    waitbox.OnButtonClick=WaitBoxBtnClicked;
00256	  }
00257	  bSHowUPDATE=false;
00258	
00259	  //listbox.List.UserDefinedItemHeight = 36;
00260	}
00261	
00262	function ShowWindow()
00263	{
00264	     OnMenu = 0; myRoot.bFired = false;
00265	     Super.ShowWindow();
00266	     bShowBCK = true;
00267	     bShowRUN = false;
00268	     bShowSEL = false;
00269	}
00270	
00271	function StartGameMsgBox(BYTE button)
00272	{
00273	  local int N;
00274	  local string GameTypeString, URL, Map;
00275	  local class<GameInfo> GameClass;
00276	  local bool FriendlyFire;
00277		local int i;
00278		local string MyClass, SkinCode;
00279	
00280	  if (button == QBTN_Yes)
00281	  {
00282	    searchGameType = xboxlive.GetSearchGameType();
00283	    searchMap = xboxlive.GetSearchMap();
00284	    searchFriendlyFire = xboxlive.GetSearchFriendlyFire();
00285	    searchLanguage = xboxlive.GetSearchLanguage();
00286	
00287	    Map = searchMap;//xboxlive.GetRandomMap(searchGameType);
00288	    if (searchFriendlyFire == 1)
00289	      FriendlyFire = true;
00290	    else
00291	      FriendlyFire = false;
00292	    xboxlive.SessionSetGameType(searchGameType);
00293	    xboxlive.SessionSetMapName(searchMap);
00294	    xboxlive.SessionSetTimeLimit(15);
00295	    xboxlive.SessionSetFragLimit(25);
00296	    xboxlive.SessionSetPublicSlots( xboxlive.GetRecommendedPlayers(map) );
00297	    xboxlive.SessionSetPrivateSlots(0);
00298	    xboxlive.SessionSetFriendlyFire(FriendlyFire);
00299	    xboxlive.SessionSetCycleLevels(true);
00300	    xboxlive.SessionSetMinSkill(SKILL_Beginner);
00301	    xboxlive.SessionSetMaxSkill(SKILL_Elite);
00302	     xboxlive.SessionSetLanguage(searchLanguage);
00303	    GameTypeString=GetRealGameTypeString(searchGameType);
00304	    GameClass = Class<XIIIMPGameInfo>(DynamicLoadObject(GameTypeString, class'Class'));
00305	    if (GameTypeString != "XIIIMP.XIIIMPGameInfo" && GameTypeString != "XIIIMP.XIIIRocketArena")
00306	      class<XIIIMPTeamGameInfo>(GameClass).default.fFriendlyFireScale = float(FriendlyFire);
00307	    N = xboxlive.GetRecommendedPlayers(map)+0;
00308	    class<XIIIMPGameInfo>(GameClass).Default.MaxPlayers = N;
00309	    //MapChanged(); GameChanged();
00310	    //URL = Map$"?Game="$GameTypeString$"?Listen";
00311	    //SaveConfigs();
00312	    myRoot.bXboxStartup = true;
00313	    myRoot.CloseMenu(true);
00314	    myRoot.CloseMenu(true);
00315	    myRoot.CloseMenu(true);
00316	    myRoot.CloseMenu(true);
00317	    Controller.OpenMenu("XIDInterf.XIIIMenuLiveAccountWindow");
00318	    XIIIMenuLiveAccountWindow(myRoot.ActivePage).AutoLoginUser = xboxlive.GetCurrentUser();
00319	    myRoot.CloseAll(true);
00320	    myRoot.GotoState('');
00321	    GetPlayerOwner().AttribPadToViewport();
00322	    GetPlayerOwner().PlayerReplicationInfo.SetPlayerName(xboxlive.GetCurrentUser());
00323	    //GetPlayerOwner().ClientTravel(URL, TRAVEL_Absolute, false);
00324	  	// skin
00325	  	MyClass = GetPlayerOwner().GetDefaultURL("MySkin");
00326	  	SkinCode = class'MeshSkinList'.default.MeshSkinListInfo[0].SkinCode;
00327	  	for (i=0;i<class'MeshSkinList'.default.MeshSkinListInfo.Length;i++)
00328	  	{
00329	  		if ( MyClass == class'MeshSkinList'.default.MeshSkinListInfo[i].SkinName )
00330	  		{
00331	  			SkinCode = class'MeshSkinList'.default.MeshSkinListInfo[i].SkinCode;
00332	  			break;
00333	  		}
00334	  	}
00335	  	
00336	
00337	      URL = Map$
00338	            "?listen"$
00339	            "?Game="$GameTypeString$
00340	            "?NP="$N$
00341	            "?FF="$FriendlyFire$
00342	            "?FR="$25$
00343	            "?TI="$15$
00344			    "?SK="$SkinCode$
00345	            "?GAMERTAG="$xboxlive.ConvertString(xboxlive.GetCurrentUser());
00346	    log("TRAVELING w/URL: "$URL);
00347	    GetPlayerOwner().ConsoleCommand("start "$URL);
00348	
00349	    //GetPlayerOwner().ConsoleCommand("start "$Map$"?Game="$GameTypeString$"?listen");
00350	  }
00351	  else
00352	  {
00353	    myRoot.CloseMenu(true);
00354	  }
00355	}
00356	
00357	function Process()
00358	{
00359	  local GUIMultiListBoxLine pack;
00360	  local XboxLiveManager.XBL_MESSAGES msg;
00361	  local int count, i;
00362	  count = 0;
00363	  msg = xboxlive.OptimatchProcessQuery();
00364	
00365	  if (msg != XBLE_NONE)
00366	  {
00367	    if (msg == XBLE_RUNNING)
00368	    { // WHOOO
00369	      UpdateMe = false;
00370	
00371	      count = xboxlive.OptimatchGetResultCount();
00372	      for (i=0; i<count; i++)
00373	      {
00374	        pack = new class'GUIMultiListBoxLine';
00375	        pack.items[0].str = xboxlive.OptimatchGetPlayerCount(i)$"/"$(xboxlive.OptimatchGetTotalPublicSlots(i) + xboxlive.OptimatchGetTotalPrivateSlots(i));
00376	        pack.items[1].tex = QoSIcons[xboxlive.OptimatchGetQoS(i)]; // QoS icon here!!
00377	        //listboxMulti.List.Add(xboxlive.GetNiceName(xboxlive.OptimatchGetMapName(i)), pack);
00378	        listboxMulti.List.Add(xboxlive.OptimatchGetOwner(i), pack);
00379	
00380	        //AJ listboxMulti.list.Add(xboxlive.OptimatchGetMapName(i)$" "$xboxlive.OptimatchGetPlayerCount(i)$"/"$xboxlive.OptimatchGetTotalPublicSlots(i));
00381	      }
00382	
00383	      if (waitbox != none)
00384	      {
00385	        myRoot.CloseMenu(true);
00386	        waitbox = none;
00387	      }
00388	
00389	      if (count == 0)
00390	      {
00391	        /*
00392	        Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
00393	        msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00394	        msgbox.SetupQuestion(noOptimatchResultString, QBTN_Continue, QBTN_Continue);
00395	        msgbox.OnButtonClick=MsgBoxBtnClicked;
00396	        msgbox.InitBox(120*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 400*fRatioX, 230*fRatioY*fScaleTo);
00397		*/
00398	        Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
00399	        msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00400	        msgbox.SetupQuestion(noGamesFoundString, QBTN_Yes|QBTN_No, QBTN_Yes);
00401	        msgbox.OnButtonClick=StartGameMsgBox;
00402	        msgbox.InitBox(120, 130, 16, 16, 400, 230);
00403	
00404	      }
00405	      else
00406	      {
00407	        ResetButtons();
00408	        bShowRUN = true;
00409	        bSHowUPDATE = true;
00410	        if (!xboxlive.OptimatchProbe())
00411	        {
00412	          Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
00413	          msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00414	          msgbox.SetupQuestion(probeFailedString, QBTN_Continue, QBTN_Continue);
00415	          msgbox.OnButtonClick=MsgBoxBtnClicked;
00416	          msgbox.InitBox(120*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 400*fRatioX, 230*fRatioY*fScaleTo);
00417	        }
00418	        else
00419	          ProbeRunning = true;
00420	      }
00421	    }
00422	    else
00423	    {
00424	      if (waitbox != none)
00425	      {
00426	        myRoot.CloseMenu(true);
00427	        waitbox = none;
00428	      }
00429	      UpdateMe = false;
00430	      //msg = xboxlive.GetLastError();
00431	      Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
00432	      msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00433	      msgbox.SetupQuestion(xboxlive.GetErrorString(msg), QBTN_Ok, QBTN_Ok);
00434	      msgbox.OnButtonClick=MsgBoxBtnClicked;
00435	      msgbox.InitBox(120*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 400*fRatioX, 230*fRatioY*fScaleTo);
00436	    }
00437	  }
00438	}
00439	
00440	function ProcessConnect()
00441	{
00442	  local int msg;
00443	  local string URL;
00444	  local XIIIMenuLiveJoinMsgBox JoinMsgbox;
00445	  local string MyClass, SkinCode;
00446		local int i;
00447	
00448	  if (xboxlive.OptimatchJoinIsFinished() /*&& (GetPlayerOwner().Level.TimeSeconds - starttime)>2.0*/)
00449	  {
00450	    ConnectingToGame = false;
00451	    // Connect to URL
00452	    URL = xboxlive.OptimatchGetURL();
00453	    
00454	    if (URL != "")
00455	    {
00456	      myRoot.CloseMenu(true);
00457	
00458	      BackFromJoin=1;
00459	      AutoLoginName=xboxlive.GetCurrentUser();
00460	      BackFromJoinNotNow=true;
00461	
00462	      Controller.OpenMenu("XIDInterf.XIIIMenuLiveJoinMsgBox");
00463	      JoinMsgbox = XIIIMenuLiveJoinMsgBox(myRoot.ActivePage);
00464	      JoinMsgbox.InitBox(220*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 220*fRatioX, 230*fRatioY*fScaleTo);//, true);
00465	      JoinMsgbox.MsgBoxStatus = 100;
00466	      JoinMsgbox.URL = URL;//$"?SK="$SkinCode;
00467	    }
00468	  }
00469	  else
00470	  {
00471	    msg = xboxlive.GetLastError();
00472	    if (msg == 0) // Still waiting?
00473	      return;
00474	
00475	    if (waitbox != none)
00476	    {
00477	      myRoot.CloseMenu(true);
00478	      waitbox = none;
00479	    }
00480	
00481	    // Error!
00482	    myRoot.CloseMenu(true);
00483	    Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
00484	    msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00485	    msgbox.SetupQuestion(failedToJoinString, QBTN_Ok, QBTN_Ok);
00486	    msgbox.OnButtonClick=MsgBoxBtnClicked;
00487	    msgbox.InitBox(120*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 400*fRatioX, 230*fRatioY*fScaleTo);
00488	    ConnectingToGame = false;
00489	  }
00490	}
00491	
00492	// if subclassed, this parent function must always be called first
00493	function string GetPageParameters()
00494	{
00495	    return Super.GetPageParameters()$"?BackFromJoin="$BackFromJoin$"?AutoLoginName="$xboxlive.ConvertString(AutoLoginName);
00496	}
00497	
00498	// if GetPageParameters() is subclassed, you'd better have this one too !
00499	function SetPageParameters(string PageParameters)
00500	{
00501	    log("SetPageParameters("$PageParameters$") called for "$self);
00502	
00503	    BackFromJoin = int(localParseOption(PageParameters, "BackFromJoin", ""));
00504	    AutoLoginName = xboxlive.UnconvertString((localParseOption(PageParameters, "AutoLoginName", "")));
00505	}
00506	
00507	event Tick(float deltatime)
00508	{
00509	  if (Controller != none && BackFromJoin==1 && !BackFromJoinNotNow)
00510	  {
00511	    log("Back from join and autologinname exist!");
00512	    //BackFromJoin=0;
00513	    //BackFromJoinNotNow=false;
00514		  myRoot.CloseMenu(true);
00515	    myRoot.CloseMenu(true);
00516	    myRoot.CloseMenu(true);
00517	    myRoot.CloseMenu(true);
00518	    //myRoot.CloseMenu(true);
00519	    log("Back from join and autologinname exist (2)");
00520	    Controller.OpenMenu("XIDInterf.XIIIMenuLiveAccountWindow", true);
00521	    XIIIMenuLiveAccountWindow(myRoot.ActivePage).AutoLoginUser = AutoLoginName;
00522	    log("Back from join and autologinname exist (3)");
00523	    return;
00524	  }
00525	}
00526	
00527	function Paint(Canvas C, float X, float Y)
00528	{
00529	  local int newsel, count, i;
00530	  local GUIMultiListBoxLine pack;
00531	  local XboxLiveManager.XBL_MESSAGES msg;
00532	  local string name;
00533	  local int temptop;
00534	  local int tempindex;
00535	
00536	  if (UpdateMe)
00537	    Process();
00538	  else if (ConnectingToGame)
00539	    ProcessConnect();
00540	  else if (probeRunning && !xboxlive.OptimatchIsProbing())
00541	  {
00542	    name = listboxMulti.List.GetItemAtIndex(listboxMulti.List.Index);
00543	    temptop = listboxMulti.List.top;
00544	    tempindex = listboxMulti.List.Index;
00545	    listboxMulti.List.Clear();
00546	    probeRunning = false;
00547	    count = xboxlive.OptimatchGetResultCount();
00548	    for (i=0; i<count; i++)
00549	    {
00550	      pack = new class'GUIMultiListBoxLine';
00551	      pack.items[0].str = xboxlive.OptimatchGetPlayerCount(i)$"/"$(xboxlive.OptimatchGetTotalPublicSlots(i) + xboxlive.OptimatchGetTotalPrivateSlots(i));
00552	      pack.items[1].tex = QoSIcons[xboxlive.OptimatchGetQoS(i)]; // QoS icon here!!
00553	      //listboxMulti.List.Add(xboxlive.GetNiceName(xboxlive.OptimatchGetMapName(i)), pack);
00554	      listboxMulti.List.Add(xboxlive.OptimatchGetOwner(i), pack);
00555	      if (name == xboxlive.OptimatchGetOwner(i))
00556	        tempindex = i;
00557	      //AJ listboxMulti.list.Add(xboxlive.OptimatchGetMapName(i)$" "$xboxlive.OptimatchGetPlayerCount(i)$"/"$xboxlive.OptimatchGetTotalPublicSlots(i));
00558	    }
00559	    if (listboxMulti.List.ItemCount>tempindex)
00560	    {
00561	      if (temptop>tempindex)
00562	        temptop = tempindex;
00563	      if (tempindex>temptop+listboxMulti.List.ItemsPerPage)
00564	        temptop = tempindex;
00565	      listboxMulti.List.top   = temptop;
00566	      listboxMulti.List.Index = tempindex;
00567	    }
00568	    //ResetButtons();
00569	  }
00570	  else if (probeRunning)
00571	  {
00572	    msg = xboxlive.OptimatchProcessQuery();
00573	    if (msg != XBLE_NONE && msg != XBLE_RUNNING)
00574	    {
00575	      // Probe failed!
00576	      probeRunning = false;
00577	    }
00578	  }
00579	
00580	  newsel = listboxMulti.list.Index;
00581	  if (newsel != oldsel)
00582	  {
00583	    oldsel = newsel;
00584	    ResetButtons();
00585	  }
00586	
00587	  Super.Paint(C, X, Y);
00588	  PaintStandardBackground(C, X, Y, TitleText);
00589	}
00590	
00591	
00592	// Called when a button is clicked
00593	function bool InternalOnClick(GUIComponent Sender)
00594	{
00595	    local int i,sel,msg;
00596	    local string URL;
00597	
00598	    if (ConnectingToGame)
00599	      return true;
00600	
00601	    sessionsel = -1;
00602	    sel = listboxMulti.list.Index;
00603	
00604	    if (sel >= 0 && sel < listboxMulti.list.Elements.length)
00605	    {
00606	      //if(true)
00607	      if((xboxlive.OptimatchGetQoS(sel) == 2))
00608	      {
00609	      	sessionsel = sel;
00610	      	Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
00611	        msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00612	        msgbox.SetupQuestion(areYouSureToJoinRed, QBTN_Ok | QBTN_Cancel, QBTN_Ok);
00613	        msgbox.OnButtonClick=MsgBoxBtnClickedForRed;
00614	        msgbox.InitBox(120*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 400*fRatioX, 230*fRatioY*fScaleTo);
00615	      }
00616	      else
00617	      if (!xboxlive.OptimatchJoinSession(sel))
00618	      {
00619	        msg = xboxlive.GetLastError();
00620	        Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
00621	        msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00622	        msgbox.SetupQuestion(failedToJoinString, QBTN_Ok, QBTN_Ok);
00623	        msgbox.OnButtonClick=MsgBoxBtnClicked;
00624	        msgbox.InitBox(120*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 400*fRatioX, 230*fRatioY*fScaleTo);
00625	      }
00626	      else
00627	      {
00628	        starttime = GetPlayerOwner().Level.TimeSeconds;
00629	        Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
00630	        msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00631	        msgbox.SetupQuestion(pleaseWaitString, 0, 0, "Connecting");
00632	        msgbox.OnButtonClick=MsgBoxBtnClicked;
00633	        msgbox.InitBox(160*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 320*fRatioX, 230*fRatioY*fScaleTo);
00634	        ConnectingToGame = true;
00635	      }
00636	    }
00637	    return true;
00638	}
00639	
00640	function MsgBoxBtnClicked(byte bButton)
00641	{
00642	  switch (bButton)
00643	  {
00644	    case QBTN_Ok:
00645	    break;
00646	    case QBTN_Continue:
00647	      myRoot.CloseMenu(true);
00648	    break;
00649	  }
00650	  //log("msgbox clicked: "$bButton);
00651	}
00652	
00653	function MsgBoxBtnClickedForRed(byte bButton)
00654	{
00655	  if(sessionsel == -1)
00656	    return;
00657	
00658	  switch (bButton)
00659	  {
00660	    case QBTN_Ok:
00661	      if (!xboxlive.OptimatchJoinSession(sessionsel))
00662	      {
00663	        //msg = xboxlive.GetLastError();
00664	        Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
00665	        msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00666	        msgbox.SetupQuestion(failedToJoinString, QBTN_Ok, QBTN_Ok);
00667	        msgbox.OnButtonClick=MsgBoxBtnClicked;
00668	        msgbox.InitBox(120*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 400*fRatioX, 230*fRatioY*fScaleTo);
00669	      }
00670	      else
00671	      {
00672	        starttime = GetPlayerOwner().Level.TimeSeconds;
00673	        Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
00674	        msgbox = XIIILiveMsgBox(myRoot.ActivePage);
00675	        msgbox.SetupQuestion(pleaseWaitString, 0, 0, "Connecting");
00676	        msgbox.OnButtonClick=MsgBoxBtnClicked;
00677	        msgbox.InitBox(160*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 320*fRatioX, 230*fRatioY*fScaleTo);
00678	        ConnectingToGame = true;
00679	      }
00680	    break;
00681	  }
00682	}
00683	
00684	function WaitBoxBtnClicked(byte bButton)
00685	{
00686	  switch (bButton)
00687	  {
00688	    case QBTN_Cancel:
00689		    xboxlive.OptimatchCancelQuery();
00690		    bSHowUPDATE=true;
00691	      myRoot.CloseMenu(true);
00692	    break;
00693	  }
00694	  //log("msgbox clicked: "$bButton);
00695	}
00696	
00697	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
00698	{
00699	  local int msg;
00700	
00701	  //log(""$Key);
00702	    if (state==1/* || state==2*/)// IST_Press // to avoid auto-repeat
00703	    {
00704	      if ((Key==0x0D/*IK_Enter*/) || (Key==0x01))
00705		    {
00706	          //Controller.FocusedControl.OnClick(Self);
00707	          InternalOnClick(Controller.FocusedControl);
00708	          return true;
00709		    }
00710		    if ((Key==0x08/*IK_Backspace*/)|| (Key==0x1B))
00711		    {
00712		        xboxlive.OptimatchCancelQuery();
00713		        myRoot.CloseMenu(true);
00714	    	    return true;
00715		    }
00716		    if (Key==0xCB && bSHowUPDATE == true)
00717		    {
00718		      myRoot.CloseMenu(true);
00719		      XIIIMenuLiveOptimatchWindow(myRoot.ActivePage).bAutoUpdate = true;
00720		
00721	        bSHowUPDATE=false;
00722		    }
00723	    }
00724	    return super.InternalOnKeyEvent(Key, state, delta);
00725	}
00726	
00727	
00728	

End Source Code