protected override void OnShowContextMenu() { if (GUIBackgroundTask.Instance.IsBusy) { return; } var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedComment = selectedItem.TVTag as TraktComment; if (selectedComment == null) { return; } var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; // Like or Unlike Comment if (selectedComment.User.Username != TraktSettings.Username) { // Like if (!selectedComment.IsLiked()) { listItem = new GUIListItem(Translation.Like); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Like; } else { // UnLike listItem = new GUIListItem(Translation.UnLike); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.UnLike; } } if (ShoutType == ShoutTypeEnum.episode && (selectedComment.ParentId == null || selectedComment.ParentId == 0)) { listItem = new GUIListItem(Translation.NextEpisode); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.NextEpisode; if (EpisodeInfo.EpisodeIdx > 1) { listItem = new GUIListItem(Translation.PreviousEpisode); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.PrevEpisode; } } listItem = new GUIListItem(TraktSettings.HideSpoilersOnShouts ? Translation.ShowSpoilers : Translation.HideSpoilers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Spoilers; // userprofile - only load for unprotected users if (!selectedComment.User.IsPrivate) { listItem = new GUIListItem(Translation.UserProfile); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.UserProfile; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case (int)ContextMenuItem.Like: GUICommon.LikeComment(selectedComment); selectedComment.Likes++; PublishCommentSkinProperties(selectedComment); break; case (int)ContextMenuItem.UnLike: GUICommon.UnLikeComment(selectedComment); if (selectedComment.Likes > 0) { selectedComment.Likes--; PublishCommentSkinProperties(selectedComment); } break; case ((int)ContextMenuItem.Spoilers): TraktSettings.HideSpoilersOnShouts = !TraktSettings.HideSpoilersOnShouts; if (hideSpoilersButton != null) { hideSpoilersButton.Selected = TraktSettings.HideSpoilersOnShouts; } PublishCommentSkinProperties(selectedComment); break; case ((int)ContextMenuItem.NextEpisode): GetNextEpisodeComments(); break; case ((int)ContextMenuItem.PrevEpisode): GetPrevEpisodeComments(); break; case ((int)ContextMenuItem.UserProfile): GUIUserProfile.CurrentUser = selectedComment.User.Username; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.UserProfile); break; default: break; } base.OnShowContextMenu(); }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedComment = selectedItem.TVTag as TraktCommentItem; if (selectedComment == null) { return; } var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; // Like or Unlike Comment if (CurrentUser != TraktSettings.Username) { // Like if (!selectedComment.Comment.IsLiked()) { listItem = new GUIListItem(Translation.Like); dlg.Add(listItem); listItem.ItemId = (int)ActivityContextMenuItem.Like; } else { // UnLike listItem = new GUIListItem(Translation.UnLike); dlg.Add(listItem); listItem.ItemId = (int)ActivityContextMenuItem.Unlike; } } listItem = new GUIListItem(TraktSettings.HideSpoilersOnShouts ? Translation.ShowSpoilers : Translation.HideSpoilers); dlg.Add(listItem); listItem.ItemId = (int)ActivityContextMenuItem.Spoilers; // if selected activity is an episode or show, add 'Season Info' if (selectedComment.Show != null) { listItem = new GUIListItem(Translation.ShowSeasonInfo); dlg.Add(listItem); listItem.ItemId = (int)ActivityContextMenuItem.ShowSeasonInfo; } // get a list of common actions to perform on the selected item if (selectedComment.Movie != null || selectedComment.Show != null) { var listItems = GetContextMenuItemsForComment(selectedComment); foreach (var item in listItems) { int itemId = item.ItemId; dlg.Add(item); item.ItemId = itemId; } } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case (int)ActivityContextMenuItem.Like: GUICommon.LikeComment(selectedComment.Comment); selectedComment.Comment.Likes++; PublishCommentSkinProperties(selectedComment); break; case (int)ActivityContextMenuItem.Unlike: GUICommon.UnLikeComment(selectedComment.Comment); if (selectedComment.Comment.Likes > 0) { selectedComment.Comment.Likes--; PublishCommentSkinProperties(selectedComment); } break; case ((int)ActivityContextMenuItem.Spoilers): TraktSettings.HideSpoilersOnShouts = !TraktSettings.HideSpoilersOnShouts; if (hideSpoilersButton != null) { hideSpoilersButton.Selected = TraktSettings.HideSpoilersOnShouts; } PublishCommentSkinProperties(selectedComment); break; case ((int)ActivityContextMenuItem.ShowSeasonInfo): GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedComment.Show.ToJSON()); break; case ((int)ActivityContextMenuItem.AddToList): if (selectedComment.Movie != null) { TraktHelper.AddRemoveMovieInUserList(selectedComment.Movie, false); } else if (selectedComment.Episode != null) { TraktHelper.AddRemoveEpisodeInUserList(selectedComment.Episode, false); } else { TraktHelper.AddRemoveShowInUserList(selectedComment.Show, false); } break; case ((int)ActivityContextMenuItem.AddToWatchList): if (selectedComment.Movie != null) { TraktHelper.AddMovieToWatchList(selectedComment.Movie, true); } else if (selectedComment.Episode != null) { TraktHelper.AddEpisodeToWatchList(selectedComment.Episode); } else { TraktHelper.AddShowToWatchList(selectedComment.Show); } break; case ((int)ActivityContextMenuItem.Shouts): if (selectedComment.Movie != null) { TraktHelper.ShowMovieShouts(selectedComment.Movie); } else if (selectedComment.Episode != null) { TraktHelper.ShowEpisodeShouts(selectedComment.Show, selectedComment.Episode); } else { TraktHelper.ShowTVShowShouts(selectedComment.Show); } break; case ((int)ActivityContextMenuItem.Rate): if (selectedComment.Movie != null) { GUICommon.RateMovie(selectedComment.Movie); } else if (selectedComment.Episode != null) { GUICommon.RateEpisode(selectedComment.Show, selectedComment.Episode); } else { GUICommon.RateShow(selectedComment.Show); } break; case ((int)ActivityContextMenuItem.Cast): if (selectedComment.Movie != null) { GUICreditsMovie.Movie = selectedComment.Movie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Cast; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename((selectedItem as GUIMovieListItem).Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); } else if (selectedComment.Show != null) { GUICreditsShow.Show = selectedComment.Show; GUICreditsShow.Type = GUICreditsShow.CreditType.Cast; GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename((selectedItem as GUIShowListItem).Images.ShowImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow); } break; case ((int)ActivityContextMenuItem.Crew): if (selectedComment.Movie != null) { GUICreditsMovie.Movie = selectedComment.Movie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Crew; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename((selectedItem as GUIMovieListItem).Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); } else if (selectedComment.Show != null) { GUICreditsShow.Show = selectedComment.Show; GUICreditsShow.Type = GUICreditsShow.CreditType.Crew; GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename((selectedItem as GUIShowListItem).Images.ShowImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow); } break; case ((int)ActivityContextMenuItem.Trailers): if (selectedComment.Movie != null) { GUICommon.ShowMovieTrailersMenu(selectedComment.Movie); } else { GUICommon.ShowTVShowTrailersMenu(selectedComment.Show, selectedComment.Episode); } break; } base.OnShowContextMenu(); }