## XIDInterf
Class XIIIMenuLiveQuickmatchWindow

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

    Core.Object
       |
       +--GUI.GUI
          |
          +--GUI.GUIComponent
             |
             +--GUI.GUIMultiComponent
                |
                +--GUI.GUIPage
                   |
                   +--XIDInterf.XIIIWindow
                      |
                      +--XIDInterf.XIIILiveWindow
                         |
                         +--XIDInterf.XIIIMenuLiveQuickmatchWindow

Direct Known Subclasses:None

class XIIIMenuLiveQuickmatchWindow
extends XIDInterf.XIIILiveWindow

Variables
`string` | `AutoLoginName`
`int` | `BackFromJoin`
`bool` | `BackFromJoinNotNow`
`bool` | `ConnectingToGame`
`bool` | `Probing`
`bool` | `StartGameQuestion`
`string` | `TitleText`
`bool` | `UpdateMe`
`string` | `connectingString`
`string` | `failedToJoinString`
`XboxLiveManager.eGameType` | `gameType`
`string` | `noGamesFoundString`
`string` | `searchingString`
`float` | `starttime`

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` | `Paint(Canvas C, float X, float Y)`
`void` | `Process()`
`void` | `ProcessConnect()`
`void` | `ProcessProbe()`
`void` | `SetPageParameters(string PageParameters)`
    // if GetPageParameters() is subclassed, you'd better have this one too !
`void` | `ShowWindow()`
`void` | `StartGameMsgBox(BYTE button)`

Source Code

    00001	class XIIIMenuLiveQuickmatchWindow extends XIIILiveWindow;
    00002
    00003	//var GUIListBox listbox;
    00004	var localized string TitleText;
    00005	var localized string connectingString;
    00006	var localized string searchingString;
    00007	var localized string noGamesFoundString;
    00008
    00009	var localized string failedToJoinString;
    00010
    00011	var bool UpdateMe;
    00012	var bool Probing;
    00013	var bool ConnectingToGame;
    00014	var float starttime;
    00015	var bool StartGameQuestion;
    00016	var int BackFromJoin;
    00017	var bool BackFromJoinNotNow;
    00018	var string AutoLoginName;
    00019
    00020
    00021
    00022
    00023	var XboxLiveManager.eGameType gameType;
    00024
    00025	function Created()
    00026	{
    00027	  local int i;
    00028	  Super.Created();
    00029	}
    00030
    00031	function InitComponent(GUIController MyController,GUIComponent MyOwner)
    00032	{
    00033	  local int numberOfAccounts;
    00034
    00035	  Super.InitComponent(MyController, MyOwner);
    00036	     //listbox = GUIListBox(Controls[0]);
    00037
    00038	     if (xboxlive == none)
    00039	  	  xboxlive=New Class'XboxLiveManager';
    00040
    00041		OnClick = InternalOnClick;
    00042
    00043	     /*
    00044	     if (xboxlive != none && xboxlive.IsNetCableIn())
    00045	     {
    00046	       listbox.list.Add("Hello");
    00047	       listbox.list.Add("World");
    00048	     }
    00049	     */
    00050	     //listbox.bVisibleWhenEmpty = true;
    00051	}
    00052
    00053	function Start(XboxLiveManager.eGameType gt)
    00054	{
    00055	  gameType = gt;
    00056	  xboxlive.QuickmatchStartQuery(gametype);
    00057	  updateMe = true;
    00058
    00059	  Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
    00060	  msgbox = XIIILiveMsgBox(myRoot.ActivePage);
    00061	  msgbox.ShowWorking=true;
    00062	  msgbox.SetupQuestion(pleaseWaitString, QBTN_Cancel, QBTN_Cancel, searchingString);
    00063	  msgbox.OnButtonClick=MsgBoxBtnClicked;
    00064	  msgbox.InitBox(160, 130, 16, 16, 320, 230);
    00065	}
    00066
    00067
    00068	function ShowWindow()
    00069	{
    00070	     OnMenu = 0; myRoot.bFired = false;
    00071	     Super.ShowWindow();
    00072	     bShowBCK = true;
    00073	     bShowRUN = false;
    00074	     bShowSEL = false;
    00075	}
    00076
    00077	function string GetGameTypeString(XboxLiveManager.eGameType gameType)
    00078	{
    00079	  switch (gameType)
    00080	  {
    00081	    case GT_DM:
    00082	      return "XIIIMP.XIIIMPGameInfo";
    00083	    case GT_TeamDM:
    00084	      return "XIIIMP.XIIIMPTeamGameInfo";
    00085	    case GT_CTF:
    00086	      return "XIIIMP.XIIIMPCTFGameInfo";
    00087	    case GT_Sabotage:
    00088	      return "XIIIMP.XIIIMPBombGame";
    00089	    case GT_Duel:
    00090	      return "XIIIMP.XIIIRocketArena";
    00091	  }
    00092
    00093	  return "";
    00094	}
    00095
    00096	function StartGameMsgBox(BYTE button)
    00097	{
    00098	  local int N;
    00099	  local string GameTypeString, URL, Map;
    00100	  local class<GameInfo> GameClass;
    00101	  local bool FriendlyFire;
    00102		local int i;
    00103		local string MyClass, SkinCode;
    00104
    00105	  if (button == QBTN_Yes)
    00106	  {
    00107	    Map = xboxlive.GetRandomMap(gameType);
    00108	    FriendlyFire = false;
    00109	    xboxlive.SessionSetGameType(gameType);
    00110	    xboxlive.SessionSetMapName(Map);
    00111	    xboxlive.SessionSetTimeLimit(15);
    00112	    xboxlive.SessionSetFragLimit(25);
    00113	    xboxlive.SessionSetPublicSlots( xboxlive.GetRecommendedPlayers(map) );
    00114	    xboxlive.SessionSetPrivateSlots(0);
    00115	    xboxlive.SessionSetFriendlyFire(FriendlyFire);
    00116	    xboxlive.SessionSetCycleLevels(true);
    00117	    xboxlive.SessionSetMinSkill(SKILL_Beginner);
    00118	    xboxlive.SessionSetMaxSkill(SKILL_Elite);
    00119	    GameTypeString=GetGameTypeString(gameType);
    00120	    GameClass = Class<XIIIMPGameInfo>(DynamicLoadObject(GameTypeString, class'Class'));
    00121	    if (GameTypeString != "XIIIMP.XIIIMPGameInfo" && GameTypeString != "XIIIMP.XIIIRocketArena")
    00122	      class<XIIIMPTeamGameInfo>(GameClass).default.fFriendlyFireScale = float(FriendlyFire);
    00123	    N = xboxlive.GetRecommendedPlayers(map)+0;
    00124	    class<XIIIMPGameInfo>(GameClass).Default.MaxPlayers = N;
    00125	    //MapChanged(); GameChanged();
    00126	    //URL = Map$"?Game="$GameTypeString$"?Listen";
    00127	    //SaveConfigs();
    00128	    myRoot.bXboxStartup = true;
    00129	    myRoot.CloseMenu(true);
    00130	    myRoot.CloseMenu(true);
    00131	    myRoot.CloseMenu(true);
    00132	    Controller.OpenMenu("XIDInterf.XIIIMenuLiveAccountWindow");
    00133	    XIIIMenuLiveAccountWindow(myRoot.ActivePage).AutoLoginUser = xboxlive.GetCurrentUser();
    00134	    myRoot.CloseAll(true);
    00135	    myRoot.GotoState('');
    00136	    GetPlayerOwner().AttribPadToViewport();
    00137	    GetPlayerOwner().PlayerReplicationInfo.SetPlayerName(xboxlive.GetCurrentUser());
    00138	    //GetPlayerOwner().ClientTravel(URL, TRAVEL_Absolute, false);
    00139	  	// skin
    00140	  	MyClass = GetPlayerOwner().GetDefaultURL("MySkin");
    00141	  	SkinCode = class'MeshSkinList'.default.MeshSkinListInfo[0].SkinCode;
    00142	  	for (i=0;i<class'MeshSkinList'.default.MeshSkinListInfo.Length;i++)
    00143	  	{
    00144	  		if ( MyClass == class'MeshSkinList'.default.MeshSkinListInfo[i].SkinName )
    00145	  		{
    00146	  			SkinCode = class'MeshSkinList'.default.MeshSkinListInfo[i].SkinCode;
    00147	  			break;
    00148	  		}
    00149	  	}
    00150
    00151
    00152	      URL = Map$
    00153	            "?listen"$
    00154	            "?Game="$GameTypeString$
    00155	            "?NP="$N$
    00156	            "?FF="$FriendlyFire$
    00157	            "?FR="$25$
    00158	            "?TI="$15$
    00159			    "?SK="$SkinCode$
    00160	            "?GAMERTAG="$xboxlive.ConvertString(xboxlive.GetCurrentUser());
    00161	    log("TRAVELING w/URL: "$URL);
    00162	    GetPlayerOwner().ConsoleCommand("start "$URL);
    00163
    00164	    //GetPlayerOwner().ConsoleCommand("start "$Map$"?Game="$GameTypeString$"?listen");
    00165	  }
    00166	  else
    00167	  {
    00168	    myRoot.CloseMenu(true);
    00169	  }
    00170	}
    00171
    00172	function Process()
    00173	{
    00174	  local XboxLiveManager.XBL_MESSAGES msg;
    00175	  local int count, i, msg2;
    00176	  count = 0;
    00177	  msg = xboxlive.QuickmatchProcessQuery();
    00178
    00179	  if (msg != XBLE_NONE)
    00180	  {
    00181	    if (msg == XBLE_RUNNING)
    00182	    { // WHOOO
    00183	      UpdateMe = false;
    00184	      count = xboxlive.QuickmatchGetResultCount();
    00185	      /*for (i=0; i<count; i++)
    00186	      {
    00187	        listbox.list.Add(xboxlive.QuickmatchGetMapName(i));
    00188	      }*/
    00189
    00190	      if (count == 0)
    00191	      { // No games found
    00192	        // Autocreate one of the requested type...
    00193	        myRoot.CloseMenu(true);
    00194	        Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
    00195	        msgbox = XIIILiveMsgBox(myRoot.ActivePage);
    00196	        msgbox.SetupQuestion(noGamesFoundString, QBTN_Yes|QBTN_No, QBTN_Yes);
    00197	        msgbox.OnButtonClick=StartGameMsgBox;
    00198	        msgbox.InitBox(120, 130, 16, 16, 400, 230);
    00199	      }
    00200	      else
    00201	      { // Found game(s)
    00202	        //Send probes to find out which games work / are best
    00203
    00204	        if (!XboxLive.QuickmatchProbe())
    00205	        {
    00206	          // Create one instead (question)
    00207	          myRoot.CloseMenu(true);
    00208	          Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
    00209	          msgbox = XIIILiveMsgBox(myRoot.ActivePage);
    00210	          msgbox.SetupQuestion(noGamesFoundString, QBTN_Yes|QBTN_No, QBTN_Yes);
    00211	          msgbox.OnButtonClick=StartGameMsgBox;
    00212	          msgbox.InitBox(120, 130, 16, 16, 400, 230);
    00213	        }
    00214	        else
    00215	        {
    00216	          Probing = true;
    00217	        }
    00218	      }
    00219	    }
    00220	    else
    00221	    {
    00222	      myRoot.CloseMenu(true);
    00223	      UpdateMe = false;
    00224	      //msg = xboxlive.GetLastError();
    00225	      Controller.OpenMenu("XIDInterf.XIIILiveMsgBox");
    00226	      msgbox = XIIILiveMsgBox(myRoot.ActivePage);
    00227	      msgbox.SetupQuestion(xboxlive.GetErrorString(msg), QBTN_Ok, QBTN_Ok);
    00228	      msgbox.OnButtonClick=MsgBoxBtnClicked;
    00229	      msgbox.InitBox(120, 130, 16, 16, 400, 230);
    00230	    }
    00231	  }
    00232	}
    00233
    00234	function ProcessProbe()
    00235	{
    00236	  local XboxLiveManager.XBL_MESSAGES msg;
    00237	  local int i, count, bestIndex, bestQOS, qos, msg2;
    00238	  if (!xboxlive.QuickmatchIsProbing())
    00239	  {
    00240	    myRoot.CloseMenu(true);
    00241	    probing = false;
    00242	    bestIndex = 0;
    00243	    bestQOS = 100;
    00244	    count = xboxlive.QuickmatchGetResultCount();
    00245
for (i=0; i<count; i++) 00246 { 00247 qos = xboxlive.QuickmatchGetQoS(i); 00248 if (qos < bestQOS) 00249 { 00250 bestIndex = i; 00251 bestQOS = qos; 00252 } 00253 } 00254 // Ok, join the bestIndex game! (best QoS) 00255 if (!xboxlive.QuickmatchJoinSession(bestIndex)) 00256 { 00257 msg2 = xboxlive.GetLastError(); 00258 Controller.OpenMenu("XIDInterf.XIIILiveMsgBox"); 00259 msgbox = XIIILiveMsgBox(myRoot.ActivePage); 00260 msgbox.SetupQuestion(failedToJoinString, QBTN_Ok, QBTN_Ok); 00261 msgbox.OnButtonClick=MsgBoxBtnClicked; 00262 msgbox.InitBox(120, 130, 16, 16, 400, 230); 00263 } 00264 else 00265 { 00266 starttime = GetPlayerOwner().Level.TimeSeconds; 00267 Controller.OpenMenu("XIDInterf.XIIILiveMsgBox"); 00268 msgbox = XIIILiveMsgBox(myRoot.ActivePage); 00269 msgbox.ShowWorking=true; 00270 msgbox.SetupQuestion(pleaseWaitString, QBTN_Cancel, QBTN_Cancel, connectingString); 00271 msgbox.OnButtonClick=MsgBoxBtnClicked; 00272 msgbox.InitBox(160, 130, 16, 16, 320, 230); 00273 ConnectingToGame = true; 00274 } 00275 } 00276 else 00277 { 00278 msg = xboxlive.QuickmatchProcessQuery(); 00279 if (msg != XBLE_NONE && msg != XBLE_RUNNING) 00280 { 00281 // Probe failed! 00282 probing = false; 00283 myRoot.CloseMenu(true); 00284 myRoot.CloseMenu(true); 00285 } 00286 } 00287 } 00288 00289 function ProcessConnect() 00290 { 00291 local int msg; 00292 local string URL; 00293 local XIIIMenuLiveJoinMsgBox JoinMsgbox; 00294 00295 if (xboxlive.QuickmatchJoinIsFinished() && (GetPlayerOwner().Level.TimeSeconds - starttime)>2.0) 00296 { 00297 ConnectingToGame = false; 00298 // Connect to URL 00299 URL = xboxlive.QuickmatchGetURL(); 00300 00301 myRoot.CloseMenu(true); 00302 00303 BackFromJoin=1; 00304 AutoLoginName=xboxlive.GetCurrentUser(); 00305 BackFromJoinNotNow=true; 00306 00307 Controller.OpenMenu("XIDInterf.XIIIMenuLiveJoinMsgBox"); 00308 JoinMsgbox = XIIIMenuLiveJoinMsgBox(myRoot.ActivePage); 00309 JoinMsgbox.InitBox(220*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 220*fRatioX, 230*fRatioY*fScaleTo);//, true); 00310 JoinMsgbox.MsgBoxStatus = 100; 00311 JoinMsgbox.URL = URL; 00312 } 00313 else 00314 { 00315 msg = xboxlive.GetLastError(); 00316 if (msg == 0) // Still waiting? 00317 return; 00318 00319 // Error! 00320 myRoot.CloseMenu(true); 00321 Controller.OpenMenu("XIDInterf.XIIILiveMsgBox"); 00322 msgbox = XIIILiveMsgBox(myRoot.ActivePage); 00323 msgbox.SetupQuestion(failedToJoinString, QBTN_Ok, QBTN_Ok); 00324 msgbox.OnButtonClick=MsgBoxBtnClicked; 00325 msgbox.InitBox(120, 130, 16, 16, 400, 230); 00326 ConnectingToGame = false; 00327 } 00328 } 00329 00330 event Tick(float deltatime) 00331 { 00332 if (BackFromJoin==1 && !BackFromJoinNotNow) 00333 { 00334 BackFromJoin=0; 00335 BackFromJoinNotNow=false; 00336 myRoot.CloseMenu(true); 00337 myRoot.CloseMenu(true); 00338 myRoot.CloseMenu(true); 00339 Controller.OpenMenu("XIDInterf.XIIIMenuLiveAccountWindow", true); 00340 XIIIMenuLiveAccountWindow(myRoot.ActivePage).AutoLoginUser = AutoLoginName; 00341 return; 00342 } 00343 } 00344 00345 function Paint(Canvas C, float X, float Y) 00346 { 00347 if (UpdateMe) 00348 Process(); 00349 00350 if (ConnectingToGame) 00351 ProcessConnect(); 00352 00353 if (Probing) 00354 ProcessProbe(); 00355 00356 Super.Paint(C, X, Y); 00357 PaintStandardBackground(C, X, Y, TitleText); 00358 } 00359 00360 // if subclassed, this parent function must always be called first 00361 function string GetPageParameters() 00362 { 00363 return Super.GetPageParameters()$"?BackFromJoin="$BackFromJoin$"?AutoLoginName="$xboxlive.ConvertString(AutoLoginName); 00364 } 00365 00366 // if GetPageParameters() is subclassed, you'd better have this one too ! 00367 function SetPageParameters(string PageParameters) 00368 { 00369 log("SetPageParameters("$PageParameters$") called for "$self); 00370 00371 BackFromJoin = int(localParseOption(PageParameters, "BackFromJoin", "")); 00372 AutoLoginName = xboxlive.UnconvertString((localParseOption(PageParameters, "AutoLoginName", ""))); 00373 } 00374 00375 // Called when a button is clicked 00376 function bool InternalOnClick(GUIComponent Sender) 00377 { 00378 //local int i,sel,msg; 00379 if (ConnectingToGame) 00380 return true; 00381 00382 /* 00383 sel = listbox.list.Index; 00384 00385 if (sel >= 0 && sel < listbox.list.Elements.length) 00386 { 00387 if (!xboxlive.QuickmatchJoinSession(sel)) 00388 { 00389 msg = xboxlive.GetLastError(); 00390 Controller.OpenMenu("XIDInterf.XIIILiveMsgBox"); 00391 msgbox = XIIILiveMsgBox(myRoot.ActivePage); 00392 msgbox.SetupQuestion(xboxlive.GetErrorString(msg), QBTN_Ok, QBTN_Ok); 00393 msgbox.OnButtonClick=MsgBoxBtnClicked; 00394 msgbox.InitBox(120*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 400*fRatioX, 230*fRatioY*fScaleTo); 00395 } 00396 else 00397 { 00398 starttime = GetPlayerOwner().Level.TimeSeconds; 00399 Controller.OpenMenu("XIDInterf.XIIILiveMsgBox"); 00400 msgbox = XIIILiveMsgBox(myRoot.ActivePage); 00401 msgbox.SetupQuestion(pleaseWaitString, 0, 0, "Connecting"); 00402 msgbox.OnButtonClick=MsgBoxBtnClicked; 00403 msgbox.InitBox(160*fRatioX, 130*fRatioY*fScaleTo, 16, 16, 320*fRatioX, 230*fRatioY*fScaleTo); 00404 ConnectingToGame = true; 00405 } 00406 } 00407 */ 00408 return true; 00409 } 00410 00411 function MsgBoxBtnClicked(byte bButton) 00412 { 00413 switch (bButton) 00414 { 00415 case QBTN_Ok: 00416 if (updateMe || probing) 00417 { 00418 xboxlive.QuickmatchCancelQuery(); 00419 myRoot.CloseMenu(true); 00420 } 00421 /*log("[XIIILiveMsgBox] Ok pressed"); 00422 xboxlive.ShutdownAndCleanup(); 00423 myRoot.CloseMenu(true); 00424 Controller.ReplaceMenu("XIDInterf.XIIIMenuLiveAccountWindow"); 00425 */ 00426 break; 00427 case QBTN_Cancel: 00428 xboxlive.QuickmatchCancelQuery(); 00429 myRoot.CloseMenu(true); 00430 break; 00431 } 00432 //log("msgbox clicked: "$bButton); 00433 } 00434 00435 function bool InternalOnKeyEvent(out byte Key, out byte State, float delta) 00436 { 00437 local int msg; 00438 if (state==1/* || state==2*/)// IST_Press // to avoid auto-repeat 00439 { 00440 if ((Key==0x0D/*IK_Enter*/) || (Key==0x01)) 00441 { 00442 //Controller.FocusedControl.OnClick(Self); 00443 InternalOnClick(Controller.FocusedControl); 00444 return true; 00445 } 00446 if ((Key==0x08/*IK_Backspace*/)|| (Key==0x1B)) 00447 { 00448 xboxlive.QuickmatchCancelQuery(); 00449 myRoot.CloseMenu(true); 00450 return true; 00451 } 00452 } 00453 return super.InternalOnKeyEvent(Key, state, delta); 00454 } 00455 00456 00457

End Source Code