/// <summary> /// Simple Prefix patch to catch Monuments panel setup exceptions. /// All we do is call (via reverse patch) the original method and painlessly catch any exceptions. /// </summary> /// <param name="__instance">Harmony original instance reference</param> /// <returns></returns> private static bool Prefix(UnlockingPanel __instance) { try { RefreshMonumentsPanelRev(__instance); } catch { Debugging.Message("caught monuments panel exception"); } // Don't call base method after this. return(false); }
public virtual bool InitPanel() { try { // Get Title _title = transform.Find("Caption").GetComponent <UILabel>(); // Get Description _description = transform.Find("Scrollable Panel/Message").GetComponent <UILabel>(); // Remove Close Button GameObject.Destroy(transform.Find("Caption/Close").gameObject); // Hide scrollbar _scrollbar = transform.Find("Scrollbar").GetComponent <UIScrollbar>(); _scrollbar.opacity = 0; // Change Dont show text _dontShowAgainCheckbox = transform.Find("DontShow").GetComponent <UICheckBox>(); transform.Find("DontShow/OnOff").GetComponent <UILabel>().text = "Don't show on future updates"; // Change ok to Options _okButton = transform.Find("Ok").GetComponent <UIButton>(); GameObject.Destroy(_okButton.GetComponent <BindEvent>()); // Change cancel to Later _cancelButton = transform.Find("Cancel").GetComponent <UIButton>(); GameObject.Destroy(_cancelButton.GetComponent <BindEvent>()); // Get fireworks UnlockingPanel paradoxPanel = UIView.GetAView().GetComponentInChildren <UnlockingPanel>(); if (paradoxPanel != null) { m_fireworks = paradoxPanel.m_Fireworks; if (m_fireworks != null) { Renderer[] componentsInChildren = this.m_fireworks.GetComponentsInChildren <Renderer>(); m_fireworkMaterials = new Material[componentsInChildren.Length]; for (int i = 0; i < componentsInChildren.Length; ++i) { m_fireworkMaterials[i] = componentsInChildren[i].material; } } } // Add panel to dynamic panels library this.name = this.GetType().Name; UIDynamicPanels.DynamicPanelInfo panelInfo = new UIDynamicPanels.DynamicPanelInfo(); typeof(UIDynamicPanels.DynamicPanelInfo).GetFieldByName("m_Name").SetValue(panelInfo, this.name); typeof(UIDynamicPanels.DynamicPanelInfo).GetFieldByName("m_PanelRoot").SetValue(panelInfo, this.GetComponent <UIPanel>()); typeof(UIDynamicPanels.DynamicPanelInfo).GetFieldByName("m_IsModal").SetValue(panelInfo, true); panelInfo.viewOwner = UIView.GetAView(); panelInfo.AddInstance(this.GetComponent <UIPanel>()); Dictionary <string, UIDynamicPanels.DynamicPanelInfo> cachedPanels = typeof(UIDynamicPanels).GetFieldByName("m_CachedPanels").GetValue(UIView.library) as Dictionary <string, UIDynamicPanels.DynamicPanelInfo>; if (!cachedPanels.ContainsKey(panelInfo.name)) { cachedPanels.Add(panelInfo.name, panelInfo); } return(true); } catch (Exception) { // TODO: log error return(false); } }