/// <summary> /// Gets the loading parameter from the hyperlinkparameter property of skin button control /// </summary> private LoadingParameter GetLoadingParameter() { LoadingParameter loadingParameter = new LoadingParameter { Type = LoadingParameterType.None }; if (string.IsNullOrEmpty(_loadParameter)) return loadingParameter; MPTVSeriesLog.Write("Parsing Loading Parameters: " + _loadParameter, MPTVSeriesLog.LogLevel.Debug); // check for legacy support (viewname only) or single parameter types if (!_loadParameter.Contains("|")) { loadingParameter.Type = LoadingParameterType.View; loadingParameter.ViewName = _loadParameter; // view only if (_loadParameter.Contains("view:")) { loadingParameter.ViewName = _loadParameter.Substring(5); } // series only if (_loadParameter.Contains("seriesid:")) { loadingParameter.Type = LoadingParameterType.Series; loadingParameter.SeriesId = _loadParameter.Substring(9); } return loadingParameter; } try { foreach (string currParam in _loadParameter.Split('|')) { string[] keyValue = currParam.Split(':'); string key = keyValue[0]; string value = keyValue[1]; switch (key.ToLowerInvariant()) { case "view": loadingParameter.Type = LoadingParameterType.View; loadingParameter.ViewName = value; break; case "seriesid": loadingParameter.Type = LoadingParameterType.Series; loadingParameter.SeriesId = value; break; case "seasonidx": loadingParameter.Type = LoadingParameterType.Season; loadingParameter.SeasonIdx = value; break; case "episodeidx": loadingParameter.Type = LoadingParameterType.Episode; loadingParameter.EpisodeIdx = value; break; default: break; } } } catch (Exception) { MPTVSeriesLog.Write("Error parsing loading parameters: " + _loadParameter); loadingParameter.Type = LoadingParameterType.None; return loadingParameter; } return loadingParameter; }
protected override void OnPageLoad() { MPTVSeriesLog.Write("OnPageLoad() started.", MPTVSeriesLog.LogLevel.Debug); if (m_Facade == null) { // Most likely the skin does not exist GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlg.Reset(); dlg.SetHeading(Translation.wrongSkin); dlg.DoModal(GetID); GUIWindowManager.ShowPreviousWindow(); return; } GUIPropertyManager.SetProperty("#currentmodule", pluginName); ImageAllocator.SetFontName(m_Facade.AlbumListLayout == null ? m_Facade.ListLayout.FontName : m_Facade.AlbumListLayout.FontName); #region Clear GUI Properties // Clear GUI Properties when first entering the plugin // This will avoid ugly property names being seen before // its corresponding value is assigned if (!m_bPluginLoaded) { clearGUIProperty(guiProperty.Subtitle); clearGUIProperty(guiProperty.Title); clearGUIProperty(guiProperty.Description); clearGUIProperty(guiProperty.CurrentView); clearGUIProperty(guiProperty.SimpleCurrentView); clearGUIProperty(guiProperty.NextView); clearGUIProperty(guiProperty.LastView); clearGUIProperty(guiProperty.SeriesCount); clearGUIProperty(guiProperty.GroupCount); clearGUIProperty(guiProperty.FilteredEpisodeCount); clearGUIProperty(guiProperty.WatchedCount); clearGUIProperty(guiProperty.UnWatchedCount); clearFieldsForskin("Series"); clearFieldsForskin("Season"); clearFieldsForskin("Episode"); } #endregion localLogos.appendEpImage = m_Episode_Image == null ? true : false; #region View Setup and Loading Parameters bool viewSwitched = false; m_LoadingParameter = GetLoadingParameter(); if (m_LoadingParameter.Type != LoadingParameterType.None && m_LoadingParameter.Type != LoadingParameterType.View) { m_JumpToViewLevel = true; if (m_allViews == null || m_allViews.Count == 0) m_allViews = logicalView.getAll(false); if (m_CurrLView == null) switchView((string)DBOption.GetOptions("lastView")); int viewLevels = m_CurrLView.m_steps.Count; m_SelectedSeries = Helper.getCorrespondingSeries(Convert.ToInt32(m_LoadingParameter.SeriesId)); if (m_SelectedSeries == null) { MPTVSeriesLog.Write("Failed to get series object from loading parameter!", MPTVSeriesLog.LogLevel.Debug); m_LoadingParameter.Type = LoadingParameterType.None; } else { MPTVSeriesLog.Write(string.Format("Loading into series: {0}", m_SelectedSeries.ToString(), MPTVSeriesLog.LogLevel.Debug)); m_stepSelection = new string[] { m_LoadingParameter.SeriesId }; m_stepSelections.Add(m_stepSelection); pushFieldsToSkin(m_SelectedSeries, "Series"); } switch (m_LoadingParameter.Type) { #region Series case LoadingParameterType.Series: // load into Season view if multiple seasons exists // will auto drill down to current available season if only one exists if (viewLevels > 1) m_CurrViewStep = viewLevels - 2; else m_CurrViewStep = 0; this.listLevel = Listlevel.Season; break; #endregion #region Season case LoadingParameterType.Season: m_SelectedSeason = Helper.getCorrespondingSeason(Convert.ToInt32(m_LoadingParameter.SeriesId), Convert.ToInt32(m_LoadingParameter.SeasonIdx)); if (m_SelectedSeason == null) { m_LoadingParameter.Type = LoadingParameterType.None; break; } // load into episode view for series/season if (viewLevels > 1) m_CurrViewStep = viewLevels - 1; else m_CurrViewStep = 0; this.listLevel = Listlevel.Episode; m_stepSelection = new string[] { m_LoadingParameter.SeriesId, m_LoadingParameter.SeasonIdx }; m_stepSelections.Add(m_stepSelection); break; #endregion #region Episode case LoadingParameterType.Episode: m_SelectedEpisode = DBEpisode.Get(Convert.ToInt32(m_LoadingParameter.SeriesId), Convert.ToInt32(m_LoadingParameter.SeasonIdx), Convert.ToInt32(m_LoadingParameter.EpisodeIdx)); if (m_SelectedEpisode == null) { m_LoadingParameter.Type = LoadingParameterType.None; break; } // load into episode view for series/season if (viewLevels > 1) m_CurrViewStep = viewLevels - 1; else m_CurrViewStep = 0; this.listLevel = Listlevel.Episode; m_stepSelection = new string[] { m_LoadingParameter.SeriesId, m_LoadingParameter.SeasonIdx }; m_stepSelections.Add(m_stepSelection); break; #endregion } setViewLabels(); } // Initialize View, also check if current view is locked after exiting and re-entering plugin if (m_LoadingParameter.Type == LoadingParameterType.None || m_LoadingParameter.Type == LoadingParameterType.View) { m_JumpToViewLevel = false; if (m_CurrLView == null || (m_CurrLView.ParentalControl && logicalView.IsLocked) || !string.IsNullOrEmpty(m_LoadingParameter.ViewName)) { // Get available Views m_allViews = logicalView.getAll(false); if (m_allViews.Count > 0) { try { if (m_LoadingParameter.Type == LoadingParameterType.View) { viewSwitched = switchView(m_LoadingParameter.ViewName); } else { viewSwitched = switchView((string)DBOption.GetOptions("lastView")); } } catch { viewSwitched = false; MPTVSeriesLog.Write("Error when switching view"); } } else { viewSwitched = false; MPTVSeriesLog.Write("Error, cannot display items because no Views have been found!"); } } else { viewSwitched = true; setViewLabels(); } // If unable to load view, exit if (!viewSwitched) { GUIWindowManager.ShowPreviousWindow(); return; } } #endregion backdrop.GUIImageOne = FanartBackground; backdrop.GUIImageTwo = FanartBackground2; backdrop.LoadingImage = loadingImage; DBEpisode previouslySelectedEpisode = m_SelectedEpisode; LoadFacade(); m_Facade.Focus = true; // Update Button Labels with translations if (viewMenuButton != null) viewMenuButton.Label = Translation.ButtonSwitchView; if (filterButton != null) filterButton.Label = Translation.Filters; if (ImportButton != null) ImportButton.Label = Translation.ButtonRunImport; if (LayoutMenuButton != null) LayoutMenuButton.Label = Translation.ButtonChangeLayout; if (OptionsMenuButton != null) OptionsMenuButton.Label = Translation.ButtonOptions; setProcessAnimationStatus(m_parserUpdaterWorking); if (m_Logos_Image != null) { logosHeight = m_Logos_Image.Height; logosWidth = m_Logos_Image.Width; } m_bPluginLoaded = true; Helper.disableNativeAutoplay(); // Ask to Rate Episode, onPageLoad is triggered after returning from player if (ask2Rate != null) { showRatingsDialog(ask2Rate, true); ask2Rate = null; // Refresh the facade if we want to see the submitted rating if (this.listLevel == Listlevel.Episode) { LoadFacade(); } } // Play after subtitle download if (m_PlaySelectedEpisodeAfterSubtitles && previouslySelectedEpisode != null && previouslySelectedEpisode == m_SelectedEpisode) { CommonPlayEpisodeAction(); m_PlaySelectedEpisodeAfterSubtitles = false; } // Push last update time to skin setGUIProperty(guiProperty.LastOnlineUpdate, DBOption.GetOptions(DBOption.cImport_OnlineUpdateScanLastTime)); MPTVSeriesLog.Write("OnPageLoad() completed.", MPTVSeriesLog.LogLevel.Debug); }