public GameInvitePopup(InvitationRequest stats) { InitializeComponent(); Client.RiotConnection.MessageReceived += PVPNet_OnMessageReceived; if (!Client.InviteData.ContainsKey(stats.InvitationId)) { LoadGamePopupData(stats); Unlock(); } else { var info = Client.InviteData[stats.InvitationId]; Client.Log("Tried to find a popup that existed but should have been blocked. ", "Error"); if (info == null) throw new NullReferenceException("Tried to find a nonexistant popup"); PVPNet_OnMessageReceived(this, stats); //This should be hidden //Visibility = Visibility.Hidden; } }
private void LoadGamePopupData(InvitationRequest stats) { invitationStateAsString = stats.InvitationStateAsString; gameMetaData = stats.GameMetaData; invitationState = stats.InvitationState; if (stats.Inviter != null) inviter = stats.Inviter.SummonerName; else inviter = stats.Owner.SummonerName; invitationID = stats.InvitationId; if (invitationID != null) NoGame.Visibility = Visibility.Hidden; var m = JsonConvert.DeserializeObject<invitationRequest>(stats.GameMetaData); queueId = m.queueId; isRanked = m.isRanked; rankedTeamName = m.rankedTeamName; mapId = m.mapId; gameTypeConfigId = m.gameTypeConfigId; gameMode = m.gameMode; gameType = m.gameType; switch (mapId) { case 1: mapName = "Summoners Rift"; break; case 8: mapName = "The Crystal Scar"; break; case 10: mapName = "The Twisted Treeline"; break; case 11: mapName = "New Summoners Rift"; break; case 12: mapName = "Howling Abyss"; break; default: mapName = "Unknown Map"; break; } var gameModeLower = Client.TitleCaseString(string.Format(gameMode.ToLower())); var gameTypeLower = Client.TitleCaseString(string.Format(gameType.ToLower())); var gameTypeRemove = gameTypeLower.Replace("_game", string.Empty); var removeAllUnder = gameTypeRemove.Replace("_", " "); if (string.IsNullOrEmpty(inviter)) inviter = "An unknown player"; mode = gameModeLower; type = removeAllUnder; RenderNotificationTextBox(inviter + " has invited you to a game"); RenderNotificationTextBox(string.Empty); RenderNotificationTextBox("Mode: " + gameModeLower); RenderNotificationTextBox("Map: " + mapName); RenderNotificationTextBox("Type: " + removeAllUnder); var y = new InviteInfo { stats = stats, popup = this, Inviter = inviter }; Client.InviteData.Add(stats.InvitationId, y); }