XIDInterf
Class XIIIMenuLiveScoreboardViewFriends

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

class XIIIMenuLiveScoreboardViewFriends
extends XIDInterf.XIIILiveWindow


Variables
 string TitleText
 Texture WhiteTex
 XboxLiveManager.eGameType gameType
           0 and 1 so we can fit all the stats we want
 int leaderboardsize
 int pageMode
           0 and 1 so we can fit all the stats we want
 int playerIndex[101]
 int rankIndex[101]
 int statDeaths[12]
 int statFlagsCaptured[12]
 int statFlagsReturned[12]
 int statGamesWon[12]
 int statGames[12]
 int statKills[12]
 int statMinutes[12]
 string statNames[12]
 int statRank[12]
 int statReady[12]
 int statSuicide[12]
 string strDeaths
 string strFetching
           0 and 1 so we can fit all the stats we want
 string strFlagsCaptured
 string strFlagsReturned
 string strGames
 string strGamesWon
 string strKills
 string strMinutes
 string strName
 string strSuicide
 string strTitle[5]
           0 and 1 so we can fit all the stats we want
 int toprankvalue
 string username


Function Summary
 void Created()
 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 Paint(Canvas C, float X, float Y)
 void ScrollStatsPage(bool scrollUp)
 void ShowWindow()



Source Code


00001	class XIIIMenuLiveScoreboardViewFriends extends XIIILiveWindow;
00002	
00003	var string TitleText;
00004	//var XIIIGUIMultiListBox listbox;
00005	var int leaderboardsize;
00006	
00007	var int toprankvalue;
00008	var string username;
00009	
00010	var texture WhiteTex;
00011	
00012	var int    statReady[12];
00013	var string statNames[12];
00014	var int    statKills[12];
00015	var int    statDeaths[12];
00016	var int    statGames[12];
00017	var int    statGamesWon[12];
00018	var int    statMinutes[12];
00019	var int    statFlagsCaptured[12];
00020	var int    statFlagsReturned[12];
00021	var int    statSuicide[12];
00022	var int	   statRank[12];
00023	
00024	// for *sorting* the list
00025	var int    playerIndex[101];
00026	var int    rankIndex[101];
00027	
00028	var localized string strName;
00029	var localized string strKills;
00030	var localized string strDeaths;
00031	var localized string strGames;
00032	var localized string strGamesWon;
00033	var localized string strMinutes;
00034	var localized string strFlagsCaptured;
00035	var localized string strFlagsReturned;
00036	var localized string strSuicide;
00037	
00038	var int pageMode; // 0 and 1 so we can fit all the stats we want
00039	
00040	var localized string strFetching;
00041	
00042	var localized string strTitle[5];
00043	
00044	var XboxLiveManager.eGameType  gameType;
00045	
00046	
00047	function Created()
00048	{
00049	  local int i;
00050	  local int j;
00051	  local int temp;
00052	  Super.Created();
00053	  
00054	  username = xboxlive.StatsGetFriendsResultName(0);
00055	  
00056	  //clear the list
00057	  for(i = 0; i < 100; i++)
00058	  {
00059	    playerIndex[i] = 999;
00060	    rankIndex[i] = 0;
00061	  }
00062	  //fill the list
00063	  for(i = 0; i <= xboxlive.StatsGetFriendsResultCount(); i++)
00064	  {
00065	    playerIndex[i] = i;
00066	    rankIndex[i] = xboxlive.StatsGetFriendsResultPosition(i);
00067	  }
00068	  
00069	  for(i = 0; i < xboxlive.StatsGetFriendsResultCount(); i++)
00070	  {
00071	    for(j = i+1; j < xboxlive.StatsGetFriendsResultCount(); j++)
00072	    {
00073	      if(rankIndex[i] == 0 && rankIndex[j] != 0)
00074	      {
00075	        temp = rankIndex[i];
00076	        rankIndex[i] = rankIndex[j];
00077	        rankIndex[j] = temp;
00078	      
00079	        temp = playerIndex[i];
00080	        playerIndex[i] = playerIndex[j];
00081	        playerIndex[j] = temp;
00082	      }
00083	    }
00084	  }
00085	  //bubble sort! ;p
00086	  for(i = 0; i < xboxlive.StatsGetFriendsResultCount(); i++)
00087	  {
00088	    for(j = i+1; j < xboxlive.StatsGetFriendsResultCount(); j++)
00089	    {
00090	      if(rankIndex[j] < rankIndex[i] && rankIndex[j] != 0)
00091	      {    	
00092	        temp = rankIndex[i];
00093	        rankIndex[i] = rankIndex[j];
00094	        rankIndex[j] = temp;
00095	      
00096	        temp = playerIndex[i];
00097	        playerIndex[i] = playerIndex[j];
00098	        playerIndex[j] = temp;
00099	      }
00100	    }
00101	  }
00102	
00103	}
00104	
00105	
00106	function InitComponent(GUIController MyController,GUIComponent MyOwner)
00107	{
00108	  local int i,j;
00109	  //local GUIMultiListBoxLine pack;
00110	
00111	  Super.InitComponent(MyController, MyOwner);
00112		OnClick = InternalOnClick;
00113	
00114	
00115	
00116	
00117	//    xboxlive.StatsGetResultName(j);
00118	//    xboxlive.StatsGetResultKills(j);
00119	    //xboxlive.StatsGetResultDeaths(j);
00120	    //xboxlive.StatsGetResultGames(j);
00121	    //xboxlive.StatsGetResultMinutes(j);
00122	}
00123	
00124	
00125	function ShowWindow()
00126	{
00127	  local int q;
00128	
00129	  OnMenu = 0; myRoot.bFired = false;
00130	  Super.ShowWindow();
00131	  bShowBCK = true;
00132	  bShowRUN = false;
00133	  bShowSEL = false;
00134	
00135	  pageMode = 0;
00136	
00137	  if (xboxlive.StatsPumpRequestFriends())
00138	    leaderboardsize = -1;
00139	  else
00140	    leaderboardsize = xboxlive.StatsGetFriendsResultCount();
00141	  if (leaderboardsize > 0)
00142	  {
00143	    toprankvalue    = 1;//xboxlive.StatsGetActiveUserRank();
00144	  }
00145	  for (q=0; q<12; q++)
00146	    statReady[q] = 0;
00147	
00148	  gameType = xboxlive.GetStatisticsType();
00149	
00150	  if (gameType == GT_DM)
00151	  {
00152	    TitleText = strTitle[0];
00153	  }
00154	  else if (gameType == GT_TeamDM)
00155	  {
00156	    TitleText = strTitle[1];
00157	  }
00158	  else if (gameType == GT_CTF)
00159	  {
00160	    TitleText = strTitle[2];
00161	  }
00162	  else if (gameType == GT_Sabotage)
00163	  {
00164	    TitleText = strTitle[3];
00165	  }
00166	  else if (gameType == GT_Ladder)
00167	  {
00168	    TitleText = strTitle[4];
00169	  }
00170	  else  // Must never happen!
00171	    TitleText = "";
00172	
00173	}
00174	
00175	function ScrollStatsPage(bool scrollUp)
00176	{
00177	  local int q;
00178	
00179	  if (leaderboardsize < 1)
00180	    return;
00181	
00182	  for (q=0; q<12; q++)
00183	    statReady[q] = 0;
00184	
00185	  if (scrollUp && leaderboardsize > 12)
00186	  {
00187	    toprankvalue -= 12;
00188	    if (toprankvalue < 1)
00189	      toprankvalue = 1;
00190	  }
00191	  else
00192	  {
00193	    if((toprankvalue + 12) <= leaderboardsize)
00194	    {
00195	      toprankvalue += 12;
00196	    }
00197	  }
00198	
00199	  /*if (scrollUp && leaderboardsize > 12)
00200	  {
00201	    if(toprankvalue != 1)
00202	    {
00203	      toprankvalue -= 12;
00204	      if (toprankvalue < 0)
00205	        toprankvalue = leaderboardsize - 12;
00206	      else if (toprankvalue == 0)
00207	        toprankvalue = 1;
00208	    }
00209	  }
00210	  else
00211	  {
00212	    toprankvalue += 12;
00213	    if (toprankvalue > leaderboardsize)
00214	      toprankvalue = 1;
00215	  }*/
00216	
00217	  //xboxlive.StatsSetRequestedRank(toprankvalue);
00218	}
00219	
00220	function Paint(Canvas C, float X, float Y)
00221	{
00222	local int q;
00223	
00224	  Super.Paint(C, X, Y);
00225	  PaintStandardBackground(C, X, Y, TitleText);
00226	
00227	
00228	  C.bUseBorder = true;
00229	
00230	  C.DrawColor = WhiteColor;
00231	
00232	  C.DrawColor.A = 210;
00233	  C.Style = 5; //ERenderStyle.STY_Alpha;
00234	
00235	  C.SetPos(45, 100);
00236	  C.DrawTile( WhiteTex, 550, 26, 0, 0, 8, 8 );
00237	
00238	  //C.DrawColor.A = 128;
00239	
00240	  C.SetPos(45, 130);
00241	  C.DrawTile( WhiteTex, 550, 250, 0, 0, 8, 8 );
00242	
00243	  C.Style = 1; //ERenderStyle.STY_Normal;
00244	
00245	
00246	
00247	  C.DrawColor = BlackColor;
00248	
00249	  //C.SetPos(50, 100);
00250	  //C.DrawText("", false);
00251	
00252	//  C.Font = font'XIIIFonts.XIIISmallFont';
00253	
00254	
00255	  C.SetPos(130, 100);
00256	  C.DrawText(strName, false);
00257	
00258	  if (gameType == GT_CTF)
00259	  {
00260	    if (pageMode == 0)
00261	    {
00262	      C.SetPos(350, 100);
00263	      C.DrawText(strFlagsCaptured$" / "$strFlagsReturned, false);
00264	
00265	      C.SetPos(510, 100);
00266	      C.DrawText(strSuicide, false);
00267	    }
00268	    else
00269	    {
00270	      C.SetPos(350, 100);
00271	      //C.DrawText(strGames$" / "$strGamesWon, false);
00272	      C.DrawText(strGames, false);
00273	
00274	      C.SetPos(510, 100);
00275	      C.DrawText(strMinutes, false);
00276	    }
00277	
00278	  }
00279	  else //if (gameType == GT_DM || gameType == GT_TeamDM || gameType == GT_Sabotage)
00280	  {
00281	
00282	    if (pageMode == 0)
00283	    {
00284	      C.SetPos(350, 100);
00285	      C.DrawText(strKills$" / "$strDeaths, false);
00286	
00287	      C.SetPos(510, 100);
00288	      C.DrawText(strSuicide, false);
00289	    }
00290	    else
00291	    {
00292	      C.SetPos(350, 100);
00293	      //C.DrawText(strGames$" / "$strGamesWon, false);
00294	      C.DrawText(strGames, false);
00295	
00296	      C.SetPos(510, 100);
00297	      C.DrawText(strMinutes, false);
00298	    }
00299	
00300	//    C.SetPos(420, 100);
00301	//    C.DrawText(strFlagsCaptured$" / "$strFlagsReturned, false);
00302	  }
00303	//  C.Font = font'XIIIFonts.PoliceF16';
00304	
00305	
00306	  if (leaderboardsize == -1)
00307	  {
00308	    if (!xboxlive.StatsPumpRequestFriends())
00309	      leaderboardsize = -1;
00310	    else
00311	      leaderboardsize = xboxlive.StatsGetFriendsResultCount();
00312	    if (leaderboardsize > 0)
00313	    {
00314	      toprankvalue    = 1;//xboxlive.StatsGetActiveUserRank();
00315	      //xboxlive.StatsSetRequestedRank(toprankvalue);
00316	    }
00317	
00318	//    leaderboardsize = xboxlive.StatsGetLeaderboardSize();
00319	    if (leaderboardsize < 1)
00320	    {
00321	      C.DrawColor = WhiteColor;
00322	      return;
00323	    }
00324	  //  toprankvalue    = xboxlive.StatsGetActiveUserRank();
00325	    //xboxlive.StatsSetRequestedRank(toprankvalue);
00326	  }
00327	
00328	  if (leaderboardsize == 0)
00329	  {
00330	    C.DrawColor = WhiteColor;
00331	    return;
00332	  }
00333	
00334	  for (q=0; q<12; q++)
00335	  {
00336	
00337	    if (toprankvalue+q > leaderboardsize)
00338	      break;
00339	
00340	    if (statReady[q] == 0)// stats are ready immediately when there is any element at all for the friends stats!!  && xboxlive.StatsIsRankReady(toprankvalue+q))
00341	    {      
00342	      statNames[q]   = xboxlive.StatsGetFriendsResultName(playerIndex[toprankvalue+q-1]);
00343	      
00344	      statKills[q]   = xboxlive.StatsGetFriendsResultKills(playerIndex[toprankvalue+q-1]);
00345	      statDeaths[q]  = xboxlive.StatsGetFriendsResultDeaths(playerIndex[toprankvalue+q-1]);
00346	      statSuicide[q] = xboxlive.StatsGetFriendsResultSuicides(playerIndex[toprankvalue+q-1]);
00347	      statGames[q]   = xboxlive.StatsGetFriendsResultGames(playerIndex[toprankvalue+q-1]);
00348	      statGamesWon[q]= xboxlive.StatsGetFriendsResultGamesWon(playerIndex[toprankvalue+q-1]);
00349	      statMinutes[q] = xboxlive.StatsGetFriendsResultMinutes(playerIndex[toprankvalue+q-1]);
00350	      
00351	      statFlagsCaptured[q] = xboxlive.StatsGetFriendsResultFlagsCap(playerIndex[toprankvalue+q-1]);
00352	      statFlagsReturned[q] = xboxlive.StatsGetFriendsResultFlagsRet(playerIndex[toprankvalue+q-1]);
00353	      
00354	      statRank[q]    = xboxlive.StatsGetFriendsResultPosition(playerIndex[toprankvalue+q-1]);
00355	
00356	      statReady[q] = 1;
00357	    }
00358	
00359	    if (statReady[q] == 1)
00360	    {
00361	      if(username == statNames[q])
00362	      {
00363	      	C.bUseBorder = false;
00364	        C.Style = 5;
00365	        C.DrawColor = WhiteColor;
00366	        C.SetPos(45, 133 + q*20);
00367	        C.DrawTile( WhiteTex, 550, 19, 0, 0, 8, 8 );
00368	        C.DrawColor = BlackColor;
00369	        C.Style = 1;
00370	        C.bUseBorder = true;
00371	      }
00372	
00373	      C.SetPos(130, 131 + q*20);
00374	      C.DrawText(statNames[q], false);
00375	
00376	      C.SetPos(50, 131 + q*20);
00377	      if(statRank[q] == 0)
00378	      {
00379	        C.DrawText("-", false);
00380	        if (pageMode == 0)
00381	        {
00382	          C.SetPos(350, 131 + q*20);
00383	          C.DrawText("- / -", false);
00384	
00385	          C.SetPos(510, 131 + q*20);
00386	          C.DrawText("-", false);
00387	        }
00388	        else
00389	        if (pageMode == 1)
00390	        {
00391	          C.SetPos(350, 131 + q*20);
00392	          C.DrawText("-", false);
00393	
00394	          C.SetPos(510, 131 + q*20);
00395	          C.DrawText("-", false);
00396	        }
00397	        else
00398	        if (pageMode == 2)
00399	        {
00400	      	  if(gameType == GT_CTF)
00401	      	  {
00402	            C.SetPos(350, 131 + q*20);
00403	            C.DrawText("- / -", false);
00404	          }
00405	        }
00406	      }
00407	      else
00408	      {
00409	      C.DrawText(statRank[q], false);
00410	
00411	      if (pageMode == 0)
00412	      {
00413	        C.SetPos(350, 131 + q*20);
00414	        if(gameType == GT_CTF)
00415	          C.DrawText(statFlagsCaptured[q] $"/"$statFlagsReturned[q], false);
00416	        else
00417	          C.DrawText(statKills[q] $"/"$statDeaths[q], false);
00418	
00419	        C.SetPos(510, 131 + q*20);
00420	        C.DrawText(statSuicide[q], false);
00421	      }
00422	      else
00423	      if (pageMode == 1)
00424	      {
00425	        C.SetPos(350, 131 + q*20);
00426	        //C.DrawText(statGames[q]$"/"$statGamesWon[q], false);
00427	        C.DrawText(statGames[q], false);
00428	
00429	        C.SetPos(510, 131 + q*20);
00430	        C.DrawText(statMinutes[q], false);
00431	      }
00432	      else
00433	      if (pageMode == 2)
00434	      {
00435	      	if(gameType == GT_CTF)
00436	      	{
00437	          C.SetPos(350, 131 + q*20);
00438	          C.DrawText(statKills[q] $"/"$statDeaths[q], false);
00439	        }
00440	      }
00441	      }
00442	    }
00443	    else
00444	    {
00445	      C.SetPos(50, 131 + q*20);
00446	      C.DrawText(0, false);
00447	
00448	      C.SetPos(100, 131 + q*20);
00449	      C.DrawText(strFetching, false);
00450	
00451	    }
00452	  }
00453	
00454	
00455	  //C.SetPos(48, 382);
00456	  //C.SetPos(230, 412);
00457	  //C.DrawText(strUpDown, false);
00458	
00459	
00460	  C.DrawColor = WhiteColor;
00461	
00462	}
00463	
00464	
00465	// Called when a button is clicked
00466	function bool InternalOnClick(GUIComponent Sender)
00467	{
00468	    local int i;
00469	    return true;
00470	}
00471	
00472	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
00473	{
00474	    if (state==1/* || state==2*/)// IST_Press // to avoid auto-repeat
00475	    {
00476	        if ((Key==0x0D/*IK_Enter*/) || (Key==0x01))
00477		    {
00478	          //Controller.FocusedControl.OnClick(Self);
00479	          InternalOnClick(Controller.FocusedControl);
00480	          return true;
00481		    }
00482		    if ((Key==0x08/*IK_Backspace*/)|| (Key==0x1B))
00483		    {
00484		        myRoot.CloseMenu(true);
00485	    	    return true;
00486		    }
00487		    if (Key==0x26/*IK_Up*/)
00488		    {
00489	          ScrollStatsPage(true);
00490	    	    return true;
00491		    }
00492		    if (Key==0x28/*IK_Down*/)
00493		    {
00494	          ScrollStatsPage(false);
00495	    	    return true;
00496		    }
00497		    if (Key==0x25/*IK_Left*/)
00498		    {
00499		      if (gameType == GT_CTF)
00500	              {
00501	              	pageMode--;
00502	              	if(pageMode < 0)
00503	              	  pageMode = 2;
00504	              }
00505	              else
00506	              {
00507		      if (pageMode == 0)
00508		        pageMode = 1;
00509		      else
00510		        pageMode = 0;
00511	              }
00512	
00513	    	  return true;
00514		    }
00515		    if (Key==0x27/*IK_Right*/)
00516		    {
00517		      if (gameType == GT_CTF)
00518	              {
00519	              	pageMode++;
00520	              	if(pageMode > 2)
00521	              	  pageMode = 0;
00522	              }
00523	              else
00524	              {
00525		      if (pageMode == 0)
00526		        pageMode = 1;
00527		      else
00528		        pageMode = 0;
00529	              }
00530	
00531	    	  return true;
00532		    }
00533	    }
00534	    return super.InternalOnKeyEvent(Key, state, delta);
00535	}
00536	
00537	
00538	

End Source Code