private void OnGetFriendsData(IGraphResult result) { this.Friends = new List <SocialFriendData>(); this.PlayerIdToFriendData = new Dictionary <string, SocialFriendData>(); this.InstalledFBIDs = new List <string>(); if (!string.IsNullOrEmpty(result.RawResult)) { object obj = new JsonParser(result.RawResult).Parse(); Dictionary <string, object> dictionary = obj as Dictionary <string, object>; List <object> list = dictionary["data"] as List <object>; for (int i = 0; i < list.Count; i++) { SocialFriendData socialFriendData = (SocialFriendData) new SocialFriendData().FromObject(list[i]); this.Friends.Add(socialFriendData); if (socialFriendData.Installed) { this.InstalledFBIDs.Add(socialFriendData.Id); } } this.CommonFriendDataActions(); } else { Service.Logger.ErrorFormat("Error fetching FB friends data: {0}", new object[] { result.Error }); } }
private void InitFacebookData() { this.friendTexture.Visible = false; ISocialDataController iSocialDataController = Service.ISocialDataController; Dictionary <string, SocialFriendData> playerIdToFriendData = iSocialDataController.PlayerIdToFriendData; SocialFriendData socialFriendData = null; if (this.player.PlayerID == Service.CurrentPlayer.PlayerId && iSocialDataController.FacebookId != null) { iSocialDataController.GetSelfPicture(new OnGetProfilePicture(this.OnGetProfilePicture), this.friendTexture); } else if (playerIdToFriendData != null && playerIdToFriendData.TryGetValue(this.player.PlayerID, out socialFriendData)) { if (!string.IsNullOrEmpty(socialFriendData.Name)) { string[] array = socialFriendData.Name.Split(new char[] { ' ' }); this.nameLabel.Text = Service.Lang.Get("PLAYER_NAME_AND_REAL_NAME", new object[] { this.player.PlayerName, array[0] }); } if (this.tab == SocialTabs.Friends) { iSocialDataController.GetFriendPicture(socialFriendData, new OnGetProfilePicture(this.OnGetProfilePicture), this.friendTexture); } } }
private void RefreshFriendData() { if (!base.IsLoaded()) { return; } List <SocialFriendData> friends = Service.Get <ISocialDataController>().Friends; this.empireGrid = base.GetElement <UXGrid>("GridEmpireFriends"); this.rebelGrid = base.GetElement <UXGrid>("GridRebelFriends"); this.empireGrid.SetTemplateItem("FriendEmpireThumb"); this.rebelGrid.SetTemplateItem("FriendRebelThumb"); this.empireGrid.Clear(); this.rebelGrid.Clear(); if (friends != null) { for (int i = 0; i < friends.Count; i++) { SocialFriendData socialFriendData = friends[i]; if (socialFriendData.PlayerData != null) { FactionType faction = socialFriendData.PlayerData.Faction; UXElement uXElement = null; if (faction == FactionType.Empire) { uXElement = this.empireGrid.CloneTemplateItem(socialFriendData.Id); UXTexture subElement = this.empireGrid.GetSubElement <UXTexture>(socialFriendData.Id, "FriendEmpirePic"); Service.Get <ISocialDataController>().GetFriendPicture(socialFriendData, new OnGetProfilePicture(this.OnGetFriendPicture), subElement); this.empireGrid.AddItem(uXElement, i); } else if (faction == FactionType.Rebel) { uXElement = this.rebelGrid.CloneTemplateItem(socialFriendData.Id); UXTexture subElement2 = this.rebelGrid.GetSubElement <UXTexture>(socialFriendData.Id, "FriendRebelPic"); Service.Get <ISocialDataController>().GetFriendPicture(socialFriendData, new OnGetProfilePicture(this.OnGetFriendPicture), subElement2); this.rebelGrid.AddItem(uXElement, i); } if (uXElement != null) { uXElement.Tag = socialFriendData.PlayerData.PlayerName + "\n" + socialFriendData.Name; UXButton uXButton = (UXButton)uXElement; if (uXButton != null) { uXButton.OnPressed = new UXButtonPressedDelegate(this.OnPressFriendButton); uXButton.OnReleased = new UXButtonReleasedDelegate(this.OnReleaseFriendButton); } } } } } this.empireGrid.RepositionItems(); this.rebelGrid.RepositionItems(); }
private void OnGetFriendsData(bool success) { if (!success) { this.CommonFriendDataActions(); return; } if (this.Friends == null) { this.CallFriendsDetailsCB(); return; } List <PlayerLBEntity> list = Service.LeaderboardController.Friends.List; Dictionary <string, PlayerLBEntity> dictionary = new Dictionary <string, PlayerLBEntity>(); int i = 0; int count = list.Count; while (i < count) { PlayerLBEntity playerLBEntity = list[i]; if (!string.IsNullOrEmpty(playerLBEntity.SocialID) && !dictionary.ContainsKey(playerLBEntity.SocialID)) { dictionary.Add(playerLBEntity.SocialID, playerLBEntity); } i++; } int j = 0; int count2 = this.Friends.Count; while (j < count2) { SocialFriendData socialFriendData = this.Friends[j]; if (dictionary.ContainsKey(socialFriendData.Id)) { socialFriendData.PlayerData = dictionary[socialFriendData.Id]; if (!this.PlayerIdToFriendData.ContainsKey(socialFriendData.PlayerData.PlayerID)) { this.PlayerIdToFriendData.Add(socialFriendData.PlayerData.PlayerID, socialFriendData); } } j++; } dictionary.Clear(); this.CommonFriendDataActions(); }
private void OnInviteToSquadClicked(UXButton button) { this.secondaryButton.Enabled = false; string fbFriendId = null; string fbAccessToken = null; Dictionary <string, SocialFriendData> playerIdToFriendData = Service.ISocialDataController.PlayerIdToFriendData; SocialFriendData socialFriendData = null; if (playerIdToFriendData != null && playerIdToFriendData.TryGetValue(this.player.PlayerID, out socialFriendData)) { fbFriendId = socialFriendData.Id; fbAccessToken = AccessToken.CurrentAccessToken.TokenString; } SquadMsg message = SquadMsgUtils.CreateSendInviteMessage(this.player.PlayerID, fbFriendId, fbAccessToken, new SquadController.ActionCallback(this.OnInviteToSquadComplete), null); Service.SquadController.TakeAction(message); Service.EventManager.SendEvent(EventId.SquadNext, null); ProcessingScreen.Show(); }
private void OnGetFriendsData(List <Dictionary <string, object> > friends) { this.Friends = new List <SocialFriendData>(); this.PlayerIdToFriendData = new Dictionary <string, SocialFriendData>(); this.InstalledFBIDs = new List <string>(); if (friends != null) { for (int i = 0; i < friends.Count; i++) { SocialFriendData socialFriendData = (SocialFriendData) new SocialFriendData().FromFriendObject(friends[i]); this.Friends.Add(socialFriendData); if (socialFriendData.Installed) { this.InstalledFBIDs.Add(socialFriendData.Id); } } this.CommonFriendDataActions(); return; } this.OnGetFriendsData(false); Service.Get <StaRTSLogger>().ErrorFormat("Error fetching FB friends data", new object[0]); }
public void GetFriendPicture(SocialFriendData friend, OnGetProfilePicture callback, object cookie) { Service.Engine.StartCoroutine(this.DownloadProfileImageCoroutine(friend.PictureURL, callback, cookie)); }