/// <summary>
    /// Adds a Stacked Menu to the Hierarchy
    /// </summary>
    /// <param name="menu">FluxMenu to Add to the Hierarchy</param>
    public void AddStackedMenu(FluxMenu menu)
    {
        if (CurrentMenu == menu)
        {
            return;
        }

        if (CurrentMenu && !CurrentMenu.IsOpen || menu.GetAnimationState() != FluxMenu.AnimationState.CloseIdle)
        {
            return;
        }

        if (!menu.Popup)
        {
            foreach (FluxMenu prevMenu in MenuStack)
            {
                HideMenu(prevMenu);
            }
        }

        if (CurrentMenu && CurrentMenu.Popup)
        {
            HideMenu(MenuStack.Pop());
            CurrentMenu = null;
        }

        MenuStack.Push(menu);

        ShowMenu(menu);
    }
    /// <summary>
    /// Adds a Stacked Menu to the Hierarchy 
    /// </summary>
    /// <param name="menu">FluxMenu to Add to the Hierarchy</param>
    public void AddStackedMenu(FluxMenu menu)
    {
        if (CurrentMenu == menu)
            return;

        if (CurrentMenu && !CurrentMenu.IsOpen || menu.GetAnimationState() != FluxMenu.AnimationState.CloseIdle)
            return;

        if (!menu.Popup)
        {
            foreach (FluxMenu prevMenu in MenuStack)
            {
                HideMenu(prevMenu);
            }
        }

        if (CurrentMenu && CurrentMenu.Popup)
        {
            HideMenu(MenuStack.Pop());
            CurrentMenu = null;
        }

        MenuStack.Push(menu);

        ShowMenu(menu);
    }
    /// <summary>
    /// Go to the Previous Menu of the Hierarchy
    /// </summary>
    public void GotoPrevious()
    {
        FluxMenu PrevMenu = MenuStack.Count > 0 ? MenuStack.Pop() : null;
        FluxMenu TopMenu  = MenuStack.Count > 0 ? MenuStack.Peek() : null;

        if (TopMenu && PrevMenu)
        {
            if (CurrentMenu && CurrentMenu.IsOpen &&
                (TopMenu.GetAnimationState() == FluxMenu.AnimationState.CloseIdle && !PrevMenu.Popup) ||
                (TopMenu.GetAnimationState() == FluxMenu.AnimationState.OpenIdle && PrevMenu.Popup))
            {
                if (MenuStack.Count > 0)
                {
                    ShowMenu(TopMenu);
                }
                else
                {
                    ShowMenu(null);
                }
            }
            else
            {
                MenuStack.Push(PrevMenu);
            }
        }
        else
        {
            MenuStack.Push(PrevMenu);
        }
    }
Beispiel #4
0
    public override void OnInspectorGUI()
    {
        FluxMenu menu = (FluxMenu)target;

        if (menu.StateManager == null)
        {
            menu.StateManager = FindMenuStateManager();
            if (!menu.StateManager)
            {
                return;
            }
        }

        GUI.backgroundColor = Color.gray;
        FluxEditor.BeginGroup();

        FluxEditor.BeginGroup("Flux Menu", new Color(1, 0.77f, 0.05f), 2, 1);
        FluxEditor.EndGroup();
        GUI.color           = Color.white;
        GUI.backgroundColor = Color.white;

        if (menu.GetMenuManager().DefaultMenu == menu)
        {
            DrawSplitter();
            GUI.contentColor = new Color(1, 0.77f, 0.05f);
            EditorGUILayout.HelpBox("This is the Default Menu", MessageType.Info);
            GUI.contentColor = Color.white;
        }
        if ((menu.GetMenuManager().ExitMenu == menu))
        {
            DrawSplitter();
            GUI.contentColor = new Color(1, 0.77f, 0.05f);
            EditorGUILayout.HelpBox("This is the Exit Menu", MessageType.Info);
            GUI.contentColor = Color.white;
        }
        DrawSplitter();
        EditorGUILayout.LabelField("Properties", EditorStyles.boldLabel);
        menu.Popup = EditorGUILayout.Toggle("Popup", menu.Popup);
        DrawSplitter();

        EditorGUILayout.BeginHorizontal();
        if (FluxEditor.Button("Make This Default"))
        {
            MakeDefault();
        }

        if (FluxEditor.Button("Make This Exit"))
        {
            MakeExit();
        }
        EditorGUILayout.EndHorizontal();

        FluxEditor.EndGroup();

        EditorUtility.SetDirty(menu);
    }
Beispiel #5
0
    private FluxMenuStateManager FindMenuStateManager()
    {
        FluxMenu menu = (FluxMenu)target;

        Transform t = menu.gameObject.transform;

        while (t.parent != null)
        {
            if (t.parent.GetComponent <FluxMenuStateManager>())
            {
                return(t.parent.gameObject.GetComponent <FluxMenuStateManager>());
            }
            t = t.parent.transform;
        }
        return(null);
    }
    /// <summary>
    /// Displays a Menu
    /// </summary>
    /// <param name="Current">Menu to be Displayed</param>
    void ShowMenu(FluxMenu Current)
    {
        bool isPrevPop = false;

        if (CurrentMenu != null && !Current.Popup)
        {
            isPrevPop = CurrentMenu.Popup;
            HideMenu(CurrentMenu);
            CurrentMenu = null;
        }

        if (Current)
        {
            CurrentMenu = Current;
            CurrentMenu.Show();
            if (!isPrevPop)
            {
                // It should be already opened
                CurrentMenu.IsOpen = true;
            }
        }
    }
    /// <summary>
    /// Removes all the Previous Hierarachy and Adds a Stacked Menu
    /// </summary>
    /// <param name="menu">FluxMenu to Add to the Hierarchy</param>
    public void SetCurrentMenu(FluxMenu menu)
    {
        if (CurrentMenu == menu)
        {
            return;
        }

        if (CurrentMenu && !CurrentMenu.IsOpen || menu.GetAnimationState() != FluxMenu.AnimationState.CloseIdle)
        {
            return;
        }

        foreach (FluxMenu prevMenu in MenuStack)
        {
            HideMenu(prevMenu);
        }

        CurrentMenu = null;

        MenuStack.Clear();

        AddStackedMenu(menu);
    }
    /// <summary>
    /// Displays a Menu
    /// </summary>
    /// <param name="Current">Menu to be Displayed</param>
    void ShowMenu(FluxMenu Current)
    {
        bool isPrevPop = false;

        if (CurrentMenu != null && !Current.Popup)
        {
            isPrevPop = CurrentMenu.Popup;
            HideMenu(CurrentMenu);
            CurrentMenu = null;
        }

        if (Current)
        {
            CurrentMenu = Current;
            CurrentMenu.Show();
            if (!isPrevPop)
            {
                // It should be already opened
                CurrentMenu.IsOpen = true;
            }
        }
    }
 /// <summary>
 /// Hides the Menu
 /// </summary>
 /// <param name="menu">Menu to be hidden</param>
 void HideMenu(FluxMenu menu)
 {
     menu.IsOpen = false;
 }
    /// <summary>
    /// Removes all the Previous Hierarachy and Adds a Stacked Menu
    /// </summary>
    /// <param name="menu">FluxMenu to Add to the Hierarchy</param>
    public void SetCurrentMenu(FluxMenu menu)
    {
        if (CurrentMenu == menu)
            return;

        if (CurrentMenu && !CurrentMenu.IsOpen || menu.GetAnimationState() != FluxMenu.AnimationState.CloseIdle)
            return;

        foreach (FluxMenu prevMenu in MenuStack)
        {
            HideMenu(prevMenu);
        }

        CurrentMenu = null;

        MenuStack.Clear();

        AddStackedMenu(menu);
    }
Beispiel #11
0
    private void MakeExit()
    {
        FluxMenu menu = (FluxMenu)target;

        menu.MakeExit();
    }
Beispiel #12
0
    private void MakeDefault()
    {
        FluxMenu menu = (FluxMenu)target;

        menu.MakeDefault();
    }
 /// <summary>
 /// Hides the Menu
 /// </summary>
 /// <param name="menu">Menu to be hidden</param>
 void HideMenu(FluxMenu menu)
 {
     menu.IsOpen = false;
 }