public void DispatchPopUp <T>(AbstractPopUpPanel.PopUpPanelData popUpPanelData, PopUpPriority popUpPriority = PopUpPriority.MediumPriority) where T : AbstractPopUpPanel { var popUpPrefab = popUpPrefabList.Find(item => item.GetType() == typeof(T)); if (popUpPrefab == null && defaultPopUpPrefab == null) { Debug.LogError("No defaultPopUpPrefab is set"); return; } AbstractPopUpPanel displayPanelPrefab = popUpPrefab ?? defaultPopUpPrefab; var scenePanelObject = availablePopUpObjects.Find(item => item.name == displayPanelPrefab.name); switch (popUpPriority) { case PopUpPriority.LowPriority: DisplayLowPriorityPopUp(popUpPanelData, displayPanelPrefab, scenePanelObject); break; case PopUpPriority.MediumPriority: DisplayMediumPriorityPopUp(popUpPanelData, displayPanelPrefab, scenePanelObject, popUpPriority); break; case PopUpPriority.HighPriority: DisplayHighPriorityPopUp(popUpPanelData, displayPanelPrefab, scenePanelObject, popUpPriority); break; } }
private void DisplayPopup(AbstractPopUpPanel displayPanel, AbstractPopUpPanel.PopUpPanelData popUpPanelData) { if (canvas == null) { canvas = FindObjectOfType <Canvas>(); } displayPanel.transform.parent = canvas.transform; displayPanel.transform.localPosition = Vector3.zero; displayPanel.transform.localRotation = Quaternion.identity; displayPanel.transform.localScale = Vector3.one; displayPanel.DisplayPopUpContent(popUpPanelData); BindPopUpWindowDelegates(displayPanel, popUpPanelData.confirmButtonPressedCallback, popUpPanelData.cancelButtonPressedCallback); if (activePopUp != displayPanel) { if (activePopUp) { activePopUp.Hide(); } activePopUp = displayPanel; } }
// Used to trigger an error to show on log received in action private void TriggerError() { AbstractPopUpPanel abstractPopUpPanel = null; AbstractPopUpPanel.PopUpPanelData popUpPanelData = null; abstractPopUpPanel.DisplayPopUpContent(popUpPanelData); }
public void IterateThroughStack() { if (popUpDataStack.Count == 0) { activePopUp = null; return; } var popUpDataElement = popUpDataStack.First.Value; popUpDataStack.RemoveFirst(); DisplayPopup(popUpDataElement.displayPanel, popUpDataElement); activePopUp = popUpDataElement.displayPanel; }
private AbstractPopUpPanel InstantiatePopUp(AbstractPopUpPanel popUp) { if (canvas == null) { canvas = FindObjectOfType <Canvas>(); } var popUpPanel = Instantiate(popUp, canvas.transform); popUpPanel.gameObject.name = popUp.gameObject.name; availablePopUpObjects.Add(popUpPanel); return(popUpPanel); }
private void BindPopUpWindowDelegates(AbstractPopUpPanel displayPanel, AbstractPopUpPanel.OnUIButtonPressed confirmButtonPressed, AbstractPopUpPanel.OnUIButtonPressed cancelButtonPressed) { if (confirmButtonPressed != null) { displayPanel.popUpPanelData.confirmButtonPressedCallback += (panel) => confirmButtonPressed(panel); } displayPanel.popUpPanelData.confirmButtonPressedCallback += ClosePopUpWindow; if (cancelButtonPressed != null) { displayPanel.popUpPanelData.cancelButtonPressedCallback += (panel) => cancelButtonPressed(panel); } displayPanel.popUpPanelData.cancelButtonPressedCallback += ClosePopUpWindow; }
private void AddToDataStack(AbstractPopUpPanel displayPanel, AbstractPopUpPanel.PopUpPanelData popUpPanelData, PopUpPriority popUpPriority) { popUpPanelData.displayPanel = displayPanel; // Add high priority to the front of the stack of incoming priority is high priority if (popUpPriority == PopUpPriority.HighPriority) { popUpDataStack.AddFirst(popUpPanelData); } else { popUpDataStack.AddLast(popUpPanelData); } if (activePopUp.gameObject.activeInHierarchy == false) { activePopUp = null; IterateThroughStack(); } }
private void OpenWebLink(AbstractPopUpPanel self) { Application.OpenURL(webLink); }
private void ClosePopUpWindow(AbstractPopUpPanel abstractPopUpPanel) { abstractPopUpPanel.Hide(); abstractPopUpPanel.Reset(); IterateThroughStack(); }
/// <summary> /// Instantiate if it does not exist in scene /// </summary> /// <param name="displayPanelPrefab"></param> /// <returns></returns> private AbstractPopUpPanel InstantiatePopUp(AbstractPopUpPanel displayPanelPrefab, AbstractPopUpPanel scenePanelObject) { return((scenePanelObject) ? scenePanelObject : InstantiatePopUp(displayPanelPrefab)); }
private void DisplayHighPriorityPopUp(AbstractPopUpPanel.PopUpPanelData popUpPanelData, AbstractPopUpPanel displayPanelPrefab, AbstractPopUpPanel scenePanelObject, PopUpPriority popUpPriority) { displayPanelPrefab = InstantiatePopUp(displayPanelPrefab, scenePanelObject); if (activePopUp) { AddToDataStack(activePopUp, activePopUp.popUpPanelData, popUpPriority); } DisplayPopup(displayPanelPrefab, popUpPanelData); }
private void DisplayLowPriorityPopUp(AbstractPopUpPanel.PopUpPanelData popUpPanelData, AbstractPopUpPanel displayPanelPrefab, AbstractPopUpPanel scenePanelObject) { if (activePopUp) { return; } displayPanelPrefab = InstantiatePopUp(displayPanelPrefab, scenePanelObject); DisplayPopup(displayPanelPrefab, popUpPanelData); }