Exemplo n.º 1
0
    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;
        }
    }
Exemplo n.º 2
0
    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);
    }
Exemplo n.º 4
0
    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);
    }
Exemplo n.º 5
0
    private void DisplayLowPriorityPopUp(AbstractPopUpPanel.PopUpPanelData popUpPanelData, AbstractPopUpPanel displayPanelPrefab, AbstractPopUpPanel scenePanelObject)
    {
        if (activePopUp)
        {
            return;
        }

        displayPanelPrefab = InstantiatePopUp(displayPanelPrefab, scenePanelObject);

        DisplayPopup(displayPanelPrefab, popUpPanelData);
    }
Exemplo n.º 6
0
    public void DispatchPopUp <T>(string title, string message, PopUpPriority popUpPriority = PopUpPriority.MediumPriority, AbstractUIPanel ownerPanel = null, AbstractPopUpPanel.OnUIButtonPressed confirmButtonPressedCallback = null, AbstractPopUpPanel.OnUIButtonPressed cancelButtonPressedCallback = null, params object[] data) where T : AbstractPopUpPanel
    {
        var popUpPanelData = new AbstractPopUpPanel.PopUpPanelData();

        popUpPanelData.title   = title;
        popUpPanelData.message = message;
        popUpPanelData.confirmButtonPressedCallback = confirmButtonPressedCallback;
        popUpPanelData.cancelButtonPressedCallback  = cancelButtonPressedCallback;
        popUpPanelData.ownerPanel = ownerPanel;
        popUpPanelData.data       = data;

        DispatchPopUp <T>(popUpPanelData, popUpPriority);
    }
Exemplo n.º 7
0
    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();
        }
    }