Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Common.UI.Popups.PopupMenu"/> class with specified menu items.
        /// </summary>
        /// <param name="items">Items.</param>
        public PopupMenu(TreeNode<CustomMenuItem> items)
        {
            mItems          = items;
            mGameObject     = null;
            mOnDestroy      = new UnityEvent();

            mChildPopupMenu = null;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Common.UI.Popups.PopupMenu"/> class with specified menu items.
        /// </summary>
        /// <param name="items">Items.</param>
        public PopupMenu(TreeNode<CustomMenuItem> items)
        {
            DebugEx.VerboseFormat("Created PopupMenu(items = {0}) object", items);

            mItems     = items;
            mOnDestroy = new UnityEvent();

            mGameObject     = null;
            mChildPopupMenu = null;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Deregisters specified popup menu.
 /// </summary>
 /// <param name="menu">Popup menu.</param>
 public static void DeregisterPopupMenu(PopupMenu menu)
 {
     if (instance != null)
     {
         if (instance.mPopupMenus.Remove(menu))
         {
             if (instance.mPopupMenus.Count == 0)
             {
                 instance.enabled = false;
                 instance.mAutoPopupItem = null;
                 instance.StopTimer();
             }
         }
         else
         {
             Debug.LogError("Failed to deregister popup menu");
         }
     }
     else
     {
         Debug.LogError("There is no PopupMenuAreaScript instance");
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Script starting callback.
        /// </summary>
        void Start()
        {
            mUi        = new MainMenuUI(this);
            mShortcuts = new List<MenuItem>();
            mPopupMenu = null;

            mUi.SetupUI();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates and displays popup menu for specified menu item.
        /// </summary>
        /// <param name="node"><see cref="Common.TreeNode`1"/> instance.</param>
        public void OnShowMenuSubItems(TreeNode<CustomMenuItem> node)
        {
            if (node.data is MenuItem)
            {
                MenuItem item = node.data as MenuItem;
                Debug.Log("MainMenuScript.OnShowMenuSubItems(" + item.name + ")");

                if (mPopupMenu != null)
                {
                    mPopupMenu.Destroy();
                }

                mPopupMenu = new PopupMenu(node);
                mPopupMenu.OnDestroy.AddListener(OnPopupMenuDestroyed);

                int index = node.parent.children.IndexOf(node);

                RectTransform menuItemTransform = transform.GetChild(0).GetChild(0).GetChild(index).transform as RectTransform; // ScrollArea/Content/NODE
                Vector3[] menuItemCorners = Utils.GetWindowCorners(menuItemTransform);

                mPopupMenu.Show(menuItemCorners[2].x, menuItemCorners[2].y);
            }
            else
            {
                Debug.LogError("Unknown menu item type");
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Handler for popup menu destroy event.
        /// </summary>
        public void OnPopupMenuDestroyed()
        {
            Debug.Log("MainMenuScript.OnPopupMenuDestroyed");

            mPopupMenu = null;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Handler for popup menu destroy event.
        /// </summary>
        public void OnPopupMenuDestroyed()
        {
            Debug.Log("PopupMenu.OnPopupMenuDestroyed");

            mChildPopupMenu = null;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Destroy this instance.
        /// </summary>
        public void Destroy()
        {
            if (mChildPopupMenu != null)
            {
                mChildPopupMenu.Destroy();
                mChildPopupMenu = null;
            }

            if (mGameObject != null)
            {
                UnityEngine.Object.Destroy(mGameObject);
                mGameObject = null;
            }

            PopupMenuAreaScript.DeregisterPopupMenu(this);

            mOnDestroy.Invoke();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Handler for popup menu destroy event.
        /// </summary>
        public void OnPopupMenuDestroyed()
        {
            DebugEx.Verbose("PopupMenu.OnPopupMenuDestroyed()");

            mChildPopupMenu = null;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Creates and displays popup menu for specified menu item.
        /// </summary>
        /// <param name="node"><see cref="Common.TreeNode`1"/> instance.</param>
        public void OnShowMenuSubItems(TreeNode<CustomMenuItem> node)
        {
            DebugEx.VerboseFormat("PopupMenu.OnShowMenuSubItems(node = {0})", node);

            if (node.data is MenuItem)
            {
                MenuItem item = node.data as MenuItem;
                DebugEx.UserInteractionFormat("PopupMenu.OnShowMenuSubItems({0})", item.name);

                if (mChildPopupMenu != null)
                {
                    mChildPopupMenu.Destroy();
                }

                mChildPopupMenu = new PopupMenu(node);
                mChildPopupMenu.mOnDestroy.AddListener(OnPopupMenuDestroyed);

                int index = node.parent.children.IndexOf(node);

                RectTransform menuItemTransform = mGameObject.transform.GetChild(0).GetChild(0).GetChild(index).transform as RectTransform; // ScrollArea/Content/NODE
                Vector3[] menuItemCorners = Utils.GetWindowCorners(menuItemTransform);

                mChildPopupMenu.Show(
                                     menuItemCorners[1].x,
                                     menuItemCorners[1].y,
                                     menuItemCorners[2].x,
                                     menuItemCorners[2].y
                                    );
            }
            else
            {
                DebugEx.Error("Unknown menu item type");
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Handler for popup menu destroy event.
        /// </summary>
        public void OnPopupMenuDestroyed()
        {
            DebugEx.Verbose("PopupMenu.OnPopupMenuDestroyed()");

            mChildPopupMenu = null;
        }
Exemplo n.º 12
0
 /// <summary>
 /// Registers specified popup menu.
 /// </summary>
 /// <param name="menu">Popup menu.</param>
 public static void RegisterPopupMenu(PopupMenu menu)
 {
     if (instance != null)
     {
         instance.mPopupMenus.Add(menu);
         instance.enabled = true;
     }
     else
     {
         Debug.LogError("There is no PopupMenuAreaScript instance");
     }
 }