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
LoadPopularShows(CurrentPage);
}
}
break;
// Layout Button
case (2):
CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex);
break;
// Sort Button
case (8):
var newSortBy = GUICommon.ShowSortMenu(TraktSettings.SortByPopularShows);
if (newSortBy != null)
{
if (newSortBy.Field != TraktSettings.SortByPopularShows.Field)
{
TraktSettings.SortByPopularShows = newSortBy;
PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
UpdateButtonState();
LoadPopularShows(CurrentPage);
}
}
break;
// Hide Watched
case (9):
PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
TraktSettings.PopularShowsHideWatched = !TraktSettings.PopularShowsHideWatched;
UpdateButtonState();
LoadPopularShows(CurrentPage);
break;
// Hide Watchlisted
case (10):
PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
TraktSettings.PopularShowsHideWatchlisted = !TraktSettings.PopularShowsHideWatchlisted;
UpdateButtonState();
LoadPopularShows(CurrentPage);
break;
// Hide Collected
case (11):
PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
TraktSettings.PopularShowsHideCollected = !TraktSettings.PopularShowsHideCollected;
UpdateButtonState();
LoadPopularShows(CurrentPage);
break;
// Hide Rated
case (12):
PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1;
TraktSettings.PopularShowsHideRated = !TraktSettings.PopularShowsHideRated;
UpdateButtonState();
LoadPopularShows(CurrentPage);
break;
default:
break;
}
base.OnClicked(controlId, control, actionType);
}