Esempio n. 1
0
        static void AddUIToStack(UIWithInput ui)
        {
            if (uiStack.Count == 0)
            {
                UIInput.MarkAllSelectionAxesOccupied();
                inputModule.gameObject.SetActive(true);
            }
            else
            {
                if (uiStack.Contains(ui))
                {
                    Debug.LogError("Adding duplicate ui: " + ui.name);
                }
                for (int i = 0; i < uiStack.Count; i++)
                {
                    uiStack[i].SetSelectablesActive(false);
                    if (i == uiStack.Count - 1)
                    {
                        UIInput.MarkActionsUnoccupied(uiStack[i].GetUsedActions());
                    }
                }
            }

            UIInput.MarkActionsOccupied(ui.GetUsedActions());
            ui.SetSelectablesActive(true);
            uiStack.Add(ui);
        }
Esempio n. 2
0
        public static void HideUIComponent(UIComponent uiObject, float fadeOutTime)
        {
            if (uiObject.canvas == null)
            {
                Debug.LogWarning(uiObject.name + " doesnt have a canvas component, cant fully disable");
                // return;
            }
            else
            {
                if (!uiObject.canvas.enabled)
                {
                    // Debug.Log(uiObject.name + " is already deisabled");
                    return;
                }
            }



            UIWithInput asInputTaker = uiObject as UIWithInput;

            if (asInputTaker != null)
            {
                RemoveUIFromStack(asInputTaker);
                // if (shownUIsWithInput.Contains(asInputTaker)) {
                //     shownUIsWithInput.Remove(asInputTaker);
                // }
            }

            int id = uiObject.GetInstanceID();


            // if (fadeOutCoroutines.ContainsKey(id)) {
            //     if (fadeOutCoroutines[id] != null) {
            //         return;
            //     }
            // }
            if (CoroutineRunning(fadeOutCoroutines, id))
            {
                return;
            }



            bool isActiveInHiearchy = TransformIsActiveInUICanvas(uiObject.baseObject.transform);

            FadeOutComponent(uiObject, fadeOutTime, isActiveInHiearchy);

            // uiObject.OnComponentClose ();
            // uiObject.baseObject.SetActive(false);
        }
Esempio n. 3
0
        static void RemoveUIFromStack(UIWithInput ui)
        {
            bool wasTop = UIIsLastInStack(ui);

            uiStack.Remove(ui);
            if (wasTop)
            {
                UIInput.MarkActionsUnoccupied(ui.GetUsedActions());

                if (uiStack.Count > 0)
                {
                    UIWithInput newTop = uiStack[uiStack.Count - 1];
                    UIInput.MarkActionsOccupied(newTop.GetUsedActions());
                    newTop.SetSelectablesActive(true);
                }
            }
        }
Esempio n. 4
0
        static void ShowPopup(bool saveSelection, UIWithInput popup, Action <UISelectable, object[], Vector2Int> onSubmit)
        {
            if (onPopupOpen != null)
            {
                onPopupOpen();
            }

            // Debug.Log("Displaying popup");

            if (saveSelection)
            {
                selectedWhenPoppedUp = UIManager.CurrentSelected();
            }

            // List<int> actions = new List<int> { settings.submitAction, settings.cancelAction };
            // List<string> hints = new List<string> { "Confirm", "Cancel" };

            // mark actions occupied if no ui open
            // if (UIManager.shownUIsWithInput.Count == 0) {
            //     // UIInput.MarkAllBaseUIInputsOccupied();
            //     UIInput.MarkActionsOccupied(actions);
            // }

            popup.SetOverrideActions(null, null);

            // Debug.Log("SHOWING POPUP");

            // UIManager.ShowUI(popup);
            UIManager.ShowUIComponent(popup, 0, 0, 0);
            popupOpen = true;

            // popup.AddActionHints(actions, hints);

            // UIManager.SetAllActiveUIsSelectableActive(false);
            popup.SubscribeToActionEvent(onSubmit);
        }
Esempio n. 5
0
        // public static HashSet<UIWithInput> shownUIsWithInput = new HashSet<UIWithInput>();

        public static void ShowUIComponent(UIComponent uiObject, float fadeInTime, float duration, float fadeOutTime)
        {
            if (uiObject.canvas == null)
            {
                Debug.LogWarning(uiObject.name + " doesnt have a canvas component, cant fully enable");
                // return;
            }
            else
            {
                int id = uiObject.GetInstanceID();
                if (StopCoroutinesIfRunning(fadeOutCoroutines, id))
                {
                    uiObject.canvas.enabled = false;
                }

                if (uiObject.canvas.enabled)
                {
                    // Debug.LogWarning(uiObject.name + " is already open...");
                    return;
                }
                // Debug.Log(uiObject.name + " Setting canvas enebaled true");
                uiObject.canvas.enabled = true;
            }
            // if (uiObject.canvas != null)


            bool isActiveInHiearchy = TransformIsActiveInUICanvas(uiObject.baseObject.transform);

            if (!isActiveInHiearchy)
            {
                Debug.LogWarning(uiObject.name + " is not active in hiearchy...");
            }

            UIWithInput asInputTaker = uiObject as UIWithInput;

            if (isActiveInHiearchy)
            {
                if (asInputTaker != null)
                {
                    AddUIToStack(asInputTaker);
                    // inputModule.gameObject.SetActive(true);
                    // shownUIsWithInput.Add(asInputTaker);
                }
            }

            // uiObject.baseObject.SetActive(true);
            FadeInComponent(uiObject, fadeInTime, duration, fadeOutTime, isActiveInHiearchy);

            if (isActiveInHiearchy)
            {
                if (asInputTaker != null)
                {
                    asInputTaker.SetSelectablesActive(true);
                    if (onAnyUISelect != null)
                    {
                        foreach (var d in onAnyUISelect.GetInvocationList())
                        {
                            asInputTaker.SubscribeToSelectEvent((Action <UISelectable, object[]>)d);
                        }
                    }
                    if (onAnyUISubmit != null)
                    {
                        foreach (var d in onAnyUISubmit.GetInvocationList())
                        {
                            asInputTaker.SubscribeToActionEvent((Action <UISelectable, object[], Vector2Int>)d);
                        }
                    }
                }
            }
        }
Esempio n. 6
0
 public static bool UIIsLastInStack(UIWithInput ui)
 {
     return(uiStack.Count > 0 && ui == uiStack[uiStack.Count - 1]);
 }