XIDInterf
Class XIIIMenuLivePlayerList

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

class XIIIMenuLivePlayerList
extends XIDInterf.XIIILiveWindow


Variables
 int counter
 XIIIGUIMultiListBox listbox
 int numberOfPlayersInList
 Texture onlineIcons[7]
 int playerListLength
 string playerListNames[100]
 XboxLiveManager.FRIEND_PACKET playerList[100]
 XIIIGUIButton statusButton
 TitleText3, strLRHelp
 string strOnlineStatus[7]
 Texture voiceIcons[3]


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 ShowWindow()
 void UpdatePlayerList(bool first)



Source Code


00001	class XIIIMenuLivePlayerList extends XIIILiveWindow;
00002	
00003	#exec OBJ LOAD FILE=XIIIXboxPacket.utx
00004	//#exec OBJ LOAD FILE=GUIContent.utx
00005	
00006	var localized string TitleText1, TitleText2, TitleText3, strLRHelp;
00007	
00008	var XIIIGUIMultiListBox listbox;
00009	var texture voiceIcons[3];
00010	var texture onlineIcons[7];
00011	
00012	var int counter;
00013	var int playerListLength;
00014	
00015	var localized string strOnlineStatus[7];
00016	
00017	var XboxLiveManager.FRIEND_PACKET playerList[100];
00018	var string                        playerListNames[100];
00019	var int                           numberOfPlayersInList;
00020	
00021	var XIIIGUIButton statusButton;
00022	
00023	enum eFriendStatus
00024	{
00025	  FRIENDSTATUS_receivedinvitation,
00026	  FRIENDSTATUS_receivedfriendrequest,
00027	  FRIENDSTATUS_sentinvitation,
00028	  FRIENDSTATUS_sentfriendrequest,
00029	  FRIENDSTATUS_onlinefriendsignedin,
00030	  FRIENDSTATUS_offline,
00031	  FRIENDSTATUS_none
00032	};
00033	
00034	
00035	function Created()
00036	{
00037	  local int i;
00038	  Super.Created();
00039	  playerListLength=0;
00040	  xboxlive.EnumerateFriends(TRUE);
00041	}
00042	
00043	function InitComponent(GUIController MyController,GUIComponent MyOwner)
00044	{
00045	  Super.InitComponent(MyController, MyOwner);
00046		OnClick = InternalOnClick;
00047	
00048	  listbox = XIIIGUIMultiListBox(Controls[0]);
00049	  listbox.bVisibleWhenEmpty = true;
00050	  listbox.ScrollBar.bVisible = false;
00051	  //listbox.WinLeft = 100;
00052	  //listbox.WinTop = 100;
00053	  listbox.SetNumberOfColumns(4);
00054	  listbox.SetColumnOffset(0, 0);
00055	  listbox.SetColumnOffset(1, 226);
00056	  listbox.SetColumnOffset(2, 256);
00057	  listbox.SetColumnOffset(3, 286);
00058	  listbox.List.UserDefinedItemHeight = 36;
00059	
00060	  voiceIcons[0]=texture'XIIIXboxPacket.CommunicatorON';
00061	  voiceIcons[1]=texture'XIIIXboxPacket.CommunicatorMUTED';
00062	  voiceIcons[2]=texture'XIIIXboxPacket.CommunicatorON';
00063	
00064	  onlineIcons[eFriendStatus.FRIENDSTATUS_receivedinvitation]=texture'XIIIXboxPacket.GameInviteReceived';
00065	  onlineIcons[eFriendStatus.FRIENDSTATUS_receivedfriendrequest]=texture'XIIIXboxPacket.FriendInviteReceived';
00066	  onlineIcons[eFriendStatus.FRIENDSTATUS_sentinvitation]=texture'XIIIXboxPacket.GameInviteSent';
00067	  onlineIcons[eFriendStatus.FRIENDSTATUS_sentfriendrequest]=texture'XIIIXboxPacket.FriendInviteSent';
00068	  onlineIcons[eFriendStatus.FRIENDSTATUS_onlinefriendsignedin]=texture'XIIIXboxPacket.FriendOnline';
00069	  onlineIcons[eFriendStatus.FRIENDSTATUS_offline]=none;
00070	  onlineIcons[eFriendStatus.FRIENDSTATUS_none]=none;
00071	
00072	
00073	  statusButton         = XIIIGUIButton(Controls[1]);
00074	  statusButton.Caption = "";
00075	
00076	  xboxlive.CachePlayerList();
00077	  UpdatePlayerList(true);
00078	}
00079	
00080	function UpdatePlayerList(bool first)
00081	{
00082	  local XboxLiveManager.FRIEND_PACKET fp;
00083	  local GUIMultiListBoxLine pack;
00084	  local string name;
00085	  local int q;
00086	  local bool hasVoice,isMuted,isTalking;
00087	  local string str;
00088	  local bool friendsUpdated;
00089	  local int nrIngamePlayers, temptop, tempindex;
00090	  local bool playerListUpdated;
00091	
00092	  playerListUpdated = xboxlive.IsPlayerListUpdated();
00093	  friendsUpdated = xboxlive.IsFriendsListChanged(); // We might have friends on the player list!!
00094	
00095	
00096	  if (!xboxlive.UpdatePlayersTalking() && !first && !friendsUpdated && !playerListUpdated)
00097	  {
00098	
00099	    statusButton.Caption = "";
00100	    if (playerListLength > 1 && listbox.list.Index < playerListLength-1)
00101	    {
00102	      str = strOnlineStatus[eFriendStatus.FRIENDSTATUS_onlinefriendsignedin];
00103	
00104	      if (playerList[listbox.list.Index].onlineStatus <= eFriendStatus.FRIENDSTATUS_sentfriendrequest)
00105	        str = strOnlineStatus[playerList[listbox.list.Index].onlineStatus];
00106	      statusButton.Caption = str;
00107	
00108	    }
00109	
00110	    return;
00111	  }
00112	
00113	
00114	  temptop   = listbox.List.top;
00115	  tempindex = listbox.List.Index;
00116	  listbox.List.Clear();
00117	
00118	  playerListLength = xboxlive.GetNumberOfPlayers();
00119	  nrIngamePlayers = 0;
00120	  for (q=0; q<playerListLength; q++)
00121	  {
00122	    if (!xboxlive.IsPlayerInGame(q))
00123	      continue;
00124	    nrIngamePlayers++;
00125	
00126	
00127	    hasVoice = xboxlive.HasPlayerVoice(q);
00128	    isMuted = xboxlive.IsPlayerMuted(q);
00129	    isTalking = xboxlive.IsPlayerTalking(q);
00130	    name = xboxlive.GetPlayerName(q);
00131	    pack = new class'GUIMultiListBoxLine';
00132	
00133	    fp = xboxlive.GetFriend(name);
00134	    // Must have some friends info also!
00135	    playerListNames[q]         = name;
00136	    playerList[q].onlineStatus = fp.onlineStatus;
00137	    playerList[q].voiceStatus  = fp.voiceStatus;
00138	    playerList[q].isOnline     = fp.isOnline;
00139	    if (name == "")
00140	    {
00141	      playerListNames[q]         = name;
00142	      playerList[q].onlineStatus = eFriendStatus.FRIENDSTATUS_none;
00143	      playerList[q].isOnline     = true;
00144	    }
00145	    pack.items[0].tex = onlineIcons[playerList[q].onlineStatus];
00146	
00147	    if (hasVoice && isTalking && !isMuted)
00148	      pack.items[1].tex = voiceIcons[2];
00149	    else
00150	      pack.items[1].tex = none;
00151	    if (hasVoice && !isMuted)
00152	      pack.items[2].tex = voiceIcons[0];
00153	    else
00154	      pack.items[2].tex = none;
00155	    if (isMuted)
00156	      pack.items[2].tex = voiceIcons[1];
00157	
00158	    listbox.List.Add(name, pack);
00159	  }
00160	
00161	
00162	
00163	  nrIngamePlayers++;
00164	
00165	//  hasVoice = xboxlive.HasPlayerVoice(q);
00166	//  isMuted = xboxlive.IsPlayerMuted(q);
00167	//  isTalking = xboxlive.IsPlayerTalking(q);
00168	  name = xboxlive.GetCurrentUser();
00169	  pack = new class'GUIMultiListBoxLine';
00170	  //fp = xboxlive.GetFriend(name);
00171	  // Must have some friends info also!
00172	  playerListNames[nrIngamePlayers-1]         = name;
00173	  playerList[nrIngamePlayers-1].onlineStatus = eFriendStatus.FRIENDSTATUS_none;//fp.onlineStatus;
00174	  playerList[nrIngamePlayers-1].voiceStatus  = 0;//fp.voiceStatus;
00175	 // playerList[nrIngamePlayers-1].isOnline     = 0;//fp.isOnline;
00176	  pack.items[0].tex = onlineIcons[playerList[nrIngamePlayers-1].onlineStatus];
00177	/*
00178	  if (hasVoice && isTalking && !isMuted)
00179	    pack.items[1].tex = voiceIcons[2];
00180	  else
00181	    pack.items[1].tex = none;
00182	  if (hasVoice && !isMuted)
00183	    pack.items[2].tex = voiceIcons[0];
00184	  else
00185	    pack.items[2].tex = none;
00186	  if (isMuted)
00187	    pack.items[2].tex = voiceIcons[1];
00188	  */
00189	  listbox.List.Add(name, pack);
00190	
00191	
00192	
00193	  if (listbox.List.ItemCount>tempindex)
00194	  {
00195	    listbox.List.top   = temptop;
00196	    listbox.List.Index = tempindex;
00197	  }
00198	
00199	
00200	
00201	  playerListLength = nrIngamePlayers;
00202	
00203	  statusButton.Caption = "";
00204	  if (playerListLength > 1 && listbox.list.Index < playerListLength-1)
00205	  {
00206	    str = "";
00207	
00208	 //Silly to say a player is offline...   if (playerList[listbox.list.Index].isOnline)
00209	      str = /*friendsList[listbox.list.Index].name $ " " $*/ strOnlineStatus[eFriendStatus.FRIENDSTATUS_onlinefriendsignedin];
00210	//    else
00211	//      str = /*friendsList[listbox.list.Index].name $ " " $*/ strOnlineStatus[eFriendStatus.FRIENDSTATUS_offline];
00212	
00213	    if (playerList[listbox.list.Index].onlineStatus <= eFriendStatus.FRIENDSTATUS_sentfriendrequest)
00214	      str = /*str $ "  " $*/ strOnlineStatus[playerList[listbox.list.Index].onlineStatus];
00215	
00216	    //C.SetPos(X+columnOffset[0]+10, Y+(H-16.0)*0.5-2);
00217	    //C.DrawText(Elements[item].Item, false);
00218	    statusButton.Caption = str;
00219	
00220	  }
00221	}
00222	
00223	function ShowWindow()
00224	{
00225	  OnMenu = 0; myRoot.bFired = false;
00226	  Super.ShowWindow();
00227	  bShowBCK = true;
00228	  bShowRUN = false;
00229	  bShowSEL = false;
00230	
00231	  xboxlive.UpdateFriends();
00232	}
00233	
00234	
00235	function Paint(Canvas C, float X, float Y)
00236	{
00237	
00238	/* AJ no room right now
00239	  if (xboxlive.IsPlaying())
00240	  {
00241	    C.DrawColor = BlackColor;
00242	    C.SetPos(260, 400);
00243	    C.DrawText(strLRHelp, false);
00244	    C.DrawColor = WhiteColor;
00245	  }
00246	*/
00247	
00248	  counter++;
00249	  Super.Paint(C, X, Y);
00250	//  PaintStandardBackground(C, X, Y, TitleText);
00251	  PaintStandardBackground3(C, X, Y, TitleText1, TitleText2, TitleText3, 1);
00252	
00253	  UpdatePlayerList(false);
00254	}
00255	
00256	
00257	// Called when a button is clicked
00258	function bool InternalOnClick(GUIComponent Sender)
00259	{
00260	  local GUIMultiListBoxLine pack;
00261	  local string name;
00262	
00263	  if (playerListLength > 1 && listbox.list.Index < playerListLength-1)//listbox.list.ItemCount != 0)
00264	  {
00265	    name = listbox.list.GetItemAtIndex(listbox.list.Index);
00266	    xboxlive.SetActiveFriend( name );
00267	
00268	    if (playerList[listbox.list.Index].onlineStatus == eFriendStatus.FRIENDSTATUS_receivedfriendrequest)
00269	      myRoot.OpenMenu("XIDInterf.XIIIMenuLivePlayerMenuSelectedGamerTag");
00270	    else if (playerList[listbox.list.Index].onlineStatus == eFriendStatus.FRIENDSTATUS_sentfriendrequest)
00271	      myRoot.OpenMenu("XIDInterf.XIIIMenuLivePlayerMenuSelectedGamerTagSentFriendRequest");
00272	    else if (xboxlive.IsFriend(name))//    playerList[listbox.list.Index].onlineStatus == eFriendStatus.FRIENDSTATUS_onlinefriendsignedin)
00273	      myRoot.OpenMenu("XIDInterf.XIIIMenuLivePlayerMenuSelectedGamerTagAlreadyFriend");
00274	
00275	    else
00276	      myRoot.OpenMenu("XIDInterf.XIIIMenuLivePlayerMenuSelectedGamerTagNothing");
00277	
00278	    return true;
00279	  }
00280	
00281	
00282	/*enum eFriendStatus
00283	{
00284	  FRIENDSTATUS_receivedinvitation,
00285	  FRIENDSTATUS_receivedfriendrequest,
00286	  FRIENDSTATUS_sentinvitation,
00287	  FRIENDSTATUS_sentfriendrequest,
00288	  FRIENDSTATUS_onlinefriendsignedin,
00289	  FRIENDSTATUS_offline,
00290	  FRIENDSTATUS_none
00291	};
00292	*/
00293	  return false;
00294	}
00295	
00296	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
00297	{
00298	    if (state==1/* || state==2*/)// IST_Press // to avoid auto-repeat
00299	    {
00300	        if ((Key==0x0D/*IK_Enter*/) || (Key==0x01))
00301		    {
00302	          //Controller.FocusedControl.OnClick(Self);
00303	          InternalOnClick(Controller.FocusedControl);
00304	          return true;
00305		    }
00306		    if ((Key==0x08/*IK_Backspace*/)|| (Key==0x1B))
00307		    {
00308		        myRoot.CloseMenu(true);
00309	    	    return true;
00310		    }
00311		    if (Key==0x25/*IK_Left*/)
00312		    {
00313	        myRoot.CloseMenu(true);
00314	        myRoot.OpenMenu("XIDInterf.XIIIMenuLiveOldPlayerList");
00315	    	  return true;
00316		    }
00317		    if (Key==0x27/*IK_Right*/)
00318		    {
00319	        myRoot.CloseMenu(true);
00320	        myRoot.OpenMenu("XIDInterf.XIIIMenuLiveFriendsMainPage");
00321	    	  return true;
00322		    }
00323	    }
00324	    return super.InternalOnKeyEvent(Key, state, delta);
00325	}
00326	
00327	
00328	

End Source Code