protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
{
// wait for any background action to finish
if (GUIBackgroundTask.Instance.IsBusy) return;
switch (controlId)
{
// Facade
case (50):
if (actionType == Action.ActionType.ACTION_SELECT_ITEM)
{
var item = Facade.SelectedListItem as GUIShowListItem;
if (item == null) return;
if (!item.IsFolder)
{
if (TraktSettings.EnableJumpToForTVShows)
{
CheckAndPlayEpisode(true);
}
else
{
if (item.Show == null) return;
GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, item.Show.ToJSON());
}
}
else
{
if (item.IsPrevPageItem)
CurrentPage--;
else
CurrentPage++;
if (CurrentPage == 1)
PreviousSelectedIndex = 0;
else
PreviousSelectedIndex = 1;
// load next / previous page
LoadTrendingShows(CurrentPage);
}
}
break;
// Layout Button
case (2):
CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex);
break;
// Sort Button
case (8):
var newSortBy = GUICommon.ShowSortMenu(TraktSettings.SortByTrendingShows);
if (newSortBy != null)
{
if (newSortBy.Field != TraktSettings.SortByTrendingShows.Field)
{
TraktSettings.SortByTrendingShows = newSortBy;
PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
UpdateButtonState();
LoadTrendingShows(CurrentPage);
}
}
break;
// Hide Watched
case (9):
PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
TraktSettings.TrendingShowsHideWatched = !TraktSettings.TrendingShowsHideWatched;
UpdateButtonState();
LoadTrendingShows(CurrentPage);
break;
// Hide Watchlisted
case (10):
PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
TraktSettings.TrendingShowsHideWatchlisted = !TraktSettings.TrendingShowsHideWatchlisted;
UpdateButtonState();
LoadTrendingShows(CurrentPage);
break;
// Hide Collected
case (11):
PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
TraktSettings.TrendingShowsHideCollected = !TraktSettings.TrendingShowsHideCollected;
UpdateButtonState();
LoadTrendingShows(CurrentPage);
break;
// Hide Rated
case (12):
PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
TraktSettings.TrendingShowsHideRated = !TraktSettings.TrendingShowsHideRated;
UpdateButtonState();
LoadTrendingShows(CurrentPage);
break;
default:
break;
}
base.OnClicked(controlId, control, actionType);
}