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();
}