/// <summary>IExplorerViewElement interface.</summary> public void SetExplorerView(ExplorerView view) { // early out if (this.m_view == view) { return; } // unhook if (this.m_view != null) { this.m_view.onRequestFilterChanged.RemoveListener(DisplaySortOption); } // assign this.m_view = view; // hook if (this.m_view != null) { this.m_view.onRequestFilterChanged.AddListener(DisplaySortOption); this.DisplaySortOption(this.m_view.requestFilter); } else { this.DisplaySortOption(null); } }
/// <summary>IExplorerViewElement interface.</summary> public void SetExplorerView(ExplorerView view) { // early out if (this.m_explorerView == view) { return; } // unhook if (this.m_subsView != null) { this.m_subsView.onModPageChanged.RemoveListener(DisplayPageNumber); } if (this.m_explorerView != null) { this.m_explorerView.onModPageChanged.RemoveListener(DisplayPageNumber); } // assign this.m_subsView = null; this.m_explorerView = view; // hook if (this.m_explorerView != null) { this.m_explorerView.onModPageChanged.AddListener(DisplayPageNumber); this.DisplayPageNumber(this.m_explorerView.modPage); } else { this.DisplayPageNumber(null); } }
private void FindViews() { if (this.m_viewsFound) { return; } this.m_explorerView = GetComponentInChildren <ExplorerView>(true); this.m_subscriptionsView = GetComponentInChildren <SubscriptionsView>(true); this.m_inspectorView = GetComponentInChildren <InspectorView>(true); this.m_loginDialog = GetComponentInChildren <LoginDialog>(true); this.m_viewsFound = true; }
private void FindViews() { if (this.m_viewsFound) { return; } this.m_explorerView = GetComponentInChildren <ExplorerView>(true); this.m_subscriptionsView = GetComponentInChildren <SubscriptionsView>(true); this.m_inspectorView = GetComponentInChildren <InspectorView>(true); this.m_loginDialog = GetComponentInChildren <LoginDialog>(true); this.m_messageDialog = GetComponentInChildren <MessageDialog>(true); this.m_reportDialog = GetComponentInChildren <ReportDialog>(true); this.m_viewsFound = true; this.m_views = this.gameObject.GetComponentsInChildren <IBrowserView>(true); }
// ---------[ EVENTS ]--------- #if UNITY_EDITOR // BUG(@jackson): There's something that needs to be done here with serialization // potentially - the dropdown seems to load the option data late? /// <summary>Fills the Dropdown options with the supplied data.</summary> private void OnValidate() { UnityEditor.EditorApplication.delayCall += () => { if (this == null || Application.isPlaying) { return; } // sync dropdown Dropdown d = this.dropdown; if (d == null) { return; } d.ClearOptions(); List <string> displayTextList = new List <string>(); foreach (OptionData option in this.options) { displayTextList.Add(option.displayText); } d.AddOptions(displayTextList); // set explorer view default sort ExplorerView view = this.GetComponentInParent <ExplorerView>(); if (view != null) { bool defaultAscending = false; string defaultField = ModIO.API.GetAllModsFilterFields.dateLive; if (this.options != null && this.options.Length > 0) { defaultAscending = this.options[0].isAscending; defaultField = this.options[0].fieldName; } var so = new UnityEditor.SerializedObject(view); so.FindProperty("defaultSortMethod.ascending").boolValue = defaultAscending; so.FindProperty("defaultSortMethod.fieldName").stringValue = defaultField; so.ApplyModifiedProperties(); } }; }
/// <summary>ISubscriptionsViewElement interface.</summary> public void SetSubscriptionsView(SubscriptionsView view) { // early out if (this.m_subscriptionsView == view) { return; } // unhook if (this.m_explorerView != null) { this.m_explorerView.onRequestFilterChanged.RemoveListener(UpdateInputField); this.GetComponent <InputField>().onEndEdit.RemoveListener(SetExplorerViewFilter); } if (this.m_subscriptionsView != null) { this.m_subscriptionsView.onNameFieldFilterChanged.RemoveListener(UpdateInputField); this.GetComponent <InputField>().onValueChanged.RemoveListener(SetSubscriptionsViewFilter); } // assign this.m_explorerView = null; this.m_subscriptionsView = view; // hook if (this.m_subscriptionsView != null) { this.m_subscriptionsView.onNameFieldFilterChanged.AddListener(UpdateInputField); this.UpdateInputField(this.m_subscriptionsView.nameFieldFilter); this.GetComponent <InputField>().onValueChanged.AddListener(SetSubscriptionsViewFilter); } else { this.UpdateInputField(string.Empty); } }
// ---------[ INITIALIZATION ]--------- /// <summary>Asserts values and initializes templates.</summary> protected virtual void Start() { Debug.Assert(this.gameObject != this.pageTemplate.gameObject, "[mod.io] The Explorer View and its Container Template cannot be the same" + " Game Object. Please create a separate Game Object for the container template."); #if UNITY_EDITOR ExplorerView[] nested = this.gameObject.GetComponentsInChildren <ExplorerView>(true); if (nested.Length > 1) { ExplorerView nestedView = nested[1]; if (nestedView == this) { nestedView = nested[0]; } Debug.LogError("[mod.io] Nesting ExplorerViews is currently not supported due to the" + " way IExplorerViewElement component parenting works." + "\nThe nested ExplorerViews must be removed to allow ExplorerView functionality." + "\nthis=" + this.gameObject.name + "\nnested=" + nestedView.gameObject.name, this); return; } #endif // -- initialize template --- this.pageTemplate.gameObject.SetActive(false); GameObject templateCopyGO; // current page templateCopyGO = GameObject.Instantiate(this.pageTemplate.gameObject, this.pageTemplate.transform.parent); templateCopyGO.name = "Mod Page A"; // TODO(@jackson): Change this... templateCopyGO.SetActive(true); templateCopyGO.transform.SetSiblingIndex(this.pageTemplate.transform.GetSiblingIndex() + 1); this.m_modPageContainer = templateCopyGO.GetComponent <ModContainer>(); this.m_modPageContainer.onItemLimitChanged += (i) => this.Refresh(); // transition page templateCopyGO = GameObject.Instantiate(this.pageTemplate.gameObject, this.pageTemplate.transform.parent); templateCopyGO.name = "Mod Page B"; templateCopyGO.SetActive(false); templateCopyGO.transform.SetSiblingIndex(this.pageTemplate.transform.GetSiblingIndex() + 2); this.m_transitionPageContainer = templateCopyGO.GetComponent <ModContainer>(); // assign view elements to this var viewElementChildren = this.gameObject.GetComponentsInChildren <IExplorerViewElement>(true); foreach (IExplorerViewElement viewElement in viewElementChildren) { viewElement.SetExplorerView(this); } // - create pages - this.UpdateModPageDisplay(); this.UpdatePageButtonInteractibility(); // - perform initial fetch - this.Refresh(); }