示例#1
0
    public UIMenuPanel FindMenuPanel(UIMenuListItem parent)
    {
        UIMenuPanel panel = panels.Find(
            delegate(UIMenuPanel mp)
        {
            return(mp.parent == parent);
        });

        return(panel);
    }
        public override void OnContexualize(string uiClassName, string contextName)
        {
            base.OnContexualize(uiClassName, contextName);

            var blankRecomPanel    = new UIMenuPanel(UITheme.Vanilla, 198f, 132f, 202f, 40f);
            var blankDlButtonPanel = new UIMenuPanel(UITheme.Vanilla, 198f, 26f, 202f, 172f);

            //var blankButtonWidgetCtx = new WidgetMenuContext( this.BlankButton, false );
            var resetButtonWidgetCtx = new WidgetMenuContext(this.ResetButton, false);
            var blankRecomWidgetCtx  = new WidgetMenuContext(blankRecomPanel, false);
            var blankDlWidgetCtx     = new WidgetMenuContext(blankDlButtonPanel, false);

            //MenuContextService.AddMenuContext( uiClassName, contextName + " Tag Blank Button", blankButtonWidgetCtx );
            MenuContextService.AddMenuContext(uiClassName, contextName + " Tag Reset Button", resetButtonWidgetCtx);
            MenuContextService.AddMenuContext(uiClassName, contextName + " Blank Recommendations List", blankRecomWidgetCtx);
            MenuContextService.AddMenuContext(uiClassName, contextName + " Blank Download Button", blankDlWidgetCtx);
        }
示例#3
0
    private UIMenuPanel CreatePanel(UIMenuListItem _parent, UIMenuList _list)
    {
        string     name = (_parent == null) ? "root" : "panel_" + _parent.Text;
        GameObject obj  = new GameObject(name);

        obj.transform.parent        = _list.ItemsContent.transform;
        obj.transform.localPosition = Vector3.zero;
        obj.transform.localScale    = Vector3.one;

        UIMenuPanel panel = obj.AddComponent <UIMenuPanel>();

        panel.Init(_parent, _list);
        panels.Add(panel);
        if (panel.parent == null)
        {
            rootPanel = panel;
        }
        return(panel);
    }
示例#4
0
    private void Hide_BotherPanels(UIMenuListItem item)
    {
        List <UIMenuListItem> childList = GetChildItems(item.Parent);

        for (int i = 0; i < childList.Count; i++)
        {
            if (childList[i] != item)
            {
                UIMenuPanel panel_bother = FindMenuPanel(childList[i]);
                if (panel_bother != null)
                {
                    if (panel_bother.isShow)
                    {
                        Hide_ChildPanel(childList[i]);
                        panel_bother.Hide();
                    }
                }
            }
        }
    }
示例#5
0
    public bool DeleteItem(UIMenuListItem item)
    {
        DeleteChildItem(item);

        Debug.Log(item.gameObject.name);
        if (item.gameObject != null)
        {
            item.gameObject.transform.parent = null;
            if (Application.isEditor)
            {
                GameObject.DestroyImmediate(item.gameObject);
            }
            else
            {
                GameObject.Destroy(item.gameObject);
            }
        }
        Items.Remove(item);

        UpdateIndex();

        UIMenuPanel panel = FindMenuPanel(item.Parent);

        if (panel != null)
        {
            panel.UpdatePosition();
        }

        int count = GetChildItems(item.Parent).Count;

        if (count == 0)
        {
            DeletePanel(item.Parent);
            if (item.Parent != null)
            {
                item.Parent.IsHaveChild = false;
            }
        }

        return(true);
    }
示例#6
0
    public void InitializeComponent()
    {
        for (int i = 0; i < Items.Count; i++)
        {
            Items[i].e_OnClick        += ItemOnClick;
            Items[i].e_OnMouseMoveIn  += ItemOnMouseMoveIn;
            Items[i].e_OnMouseMoveOut += ItemOnMouseMoveOut;
        }

        for (int i = 0; i < panels.Count; i++)
        {
            if (panels[i].gameObject.name == "root")
            {
                rootPanel = panels[i];
            }
            panels[i].Hide();
        }
        if (rootPanel != null)
        {
            rootPanel.Show();
        }
    }
示例#7
0
    void ItemOnMouseMoveOut(object sender)
    {
        UIMenuListItem item = sender as UIMenuListItem;

        if (item != null)
        {
            bool        ok    = true;
            UIMenuPanel panel = FindMenuPanel(item);
            if (panel != null)
            {
                if (panel.isShow)
                {
                    ok = false;
                }
            }
            if (ok)
            {
                item.ItemSelectedBg.enabled = false;
            }
        }
        e_ItemOnMouseMoveOut.Send(eventReceiver, sender);
    }
//	[SerializeField] UIFlowing mTopFlow;
//	[SerializeField] UIFlowing mButtomFlow;

    // Use this for initialization
    void Start()
    {
        panel = transform.parent.GetComponent <UIMenuPanel>();

        if (panel == null)
        {
            return;
        }
        // pivot
        sprBg_1.pivot     = panel.spBg.pivot;
        texSPeaular.pivot = panel.spBg.pivot;

        // pos
        Vector3 vec = panel.spBg.transform.localPosition;

        texSPeaular.transform.localPosition = vec;
        sprBg_1.transform.localPosition     = vec;



//		if (panel.spBg.pivot == UIWidget.Pivot.Left)
//		{
//			float y = panel.spBg.transform.localScale.y/2;
//			mTopFlow.BeginPosition = new Vector3 (mTopFlow.BeginPosition.x,y,mTopFlow.BeginPosition.z);
//			mTopFlow.EndPosition = new Vector3 (mTopFlow.EndPosition.x,y,mTopFlow.EndPosition.z);
//			y = panel.spBg.transform.localScale.y/2 - 4;
//			mButtomFlow.BeginPosition = new Vector3 (mButtomFlow.BeginPosition.x,-y,mButtomFlow.BeginPosition.z);
//			mButtomFlow.EndPosition = new Vector3 (mButtomFlow.EndPosition.x,-y,mButtomFlow.EndPosition.z);
//		}
//		else  if (panel.spBg.pivot == UIWidget.Pivot.Bottom )
//		{
//			float y = panel.spBg.transform.localScale.y/2 - 3;
//			mTopFlow.BeginPosition = new Vector3 (mTopFlow.BeginPosition.x,y,mTopFlow.BeginPosition.z);
//			mTopFlow.EndPosition = new Vector3 (mTopFlow.EndPosition.x,y,mTopFlow.EndPosition.z);
//			y = panel.spBg.transform.localScale.y/2 - 3;
//			mButtomFlow.BeginPosition = new Vector3 (mButtomFlow.BeginPosition.x,-y,mButtomFlow.BeginPosition.z);
//			mButtomFlow.EndPosition = new Vector3 (mButtomFlow.EndPosition.x,-y,mButtomFlow.EndPosition.z);
//		}
    }
示例#9
0
    private void Hide_ChildPanel(UIMenuListItem item)
    {
        List <UIMenuListItem> childList = GetChildItems(item);

        for (int i = 0; i < childList.Count; i++)
        {
            if (childList[i].IsHaveChild)
            {
                UIMenuPanel panel_child = FindMenuPanel(childList[i]);
                if (panel_child != null)
                {
                    if (panel_child.isShow)
                    {
                        if (childList[i].IsHaveChild)
                        {
                            Hide_ChildPanel(childList[i]);
                        }
                        panel_child.Hide();
                    }
                }
            }
        }
    }
示例#10
0
    private void DeletePanel(UIMenuListItem parent)
    {
        UIMenuPanel panel = FindMenuPanel(parent);

        if (panel == null)
        {
            return;
        }

        if (panel.gameObject != null)
        {
            panel.gameObject.transform.parent = null;
            if (Application.isEditor)
            {
                GameObject.DestroyImmediate(panel.gameObject);
            }
            else
            {
                GameObject.Destroy(panel.gameObject);
            }
        }
        panels.Remove(panel);
    }
示例#11
0
        protected override ActionStatus Run(IGameAction gameAction, IScenarioContent content, MenuArgs args, out string error)
        {
            ScenarioAction action;

            if (!ParseAction <ScenarioAction>(gameAction, out action, out error))
            {
                return(ActionStatus.Error);
            }

            // 重置变量为-1
            ScenarioBlackboard.Set(args.menuName, -1);

            // 打开UI
            UIMenuPanel panel = UIManager.views.OpenView <UIMenuPanel>(UINames.k_UIMenuPanel, false);

            // 设置选项并传入选择后的处理方法
            if (!panel.SetOptions(args.options, selected =>
            {
                // 选择完成后的处理

                // 关闭菜单UI
                UIManager.views.CloseView(UINames.k_UIMenuPanel);
                // 设置选择的按钮
                ScenarioBlackboard.Set(args.menuName, selected);
                // 继续剧本
                action.MenuDone();
            }))
            {
                error = string.Format(
                    "{0} ParseArgs error: set menu options error.",
                    typeName);
                return(ActionStatus.Error);
            }

            error = null;
            return(ActionStatus.WaitMenuOption);
        }
示例#12
0
    public UIMenuListItem AddItem(UIMenuListItem parent, string text, UIGameMenuCtrl.MenuItemFlag flag, string icoName = "")
    {
        GameObject obj = AddObj();

        UIMenuPanel panel = FindMenuPanel(parent);

        if (panel == null)
        {
            panel = CreatePanel(parent, this);
        }

        UIMenuListItem item = obj.GetComponent <UIMenuListItem>();

        item.Text              = text;
        item.Parent            = parent;
        item.icoName           = icoName;
        item.mMenuItemFlag     = flag;
        item.e_OnClick        += ItemOnClick;
        item.e_OnMouseMoveIn  += ItemOnMouseMoveIn;
        item.e_OnMouseMoveOut += ItemOnMouseMoveOut;

        obj.transform.parent        = panel.content.transform;
        obj.transform.localScale    = Vector3.one;
        obj.transform.localPosition = Vector3.zero;

        Items.Insert(Items.Count, item);
        UpdateIndex();
        panel.UpdatePosition();

        if (parent != null)
        {
            parent.IsHaveChild = true;
        }

        return(item);
    }
示例#13
0
    // event
    void ItemOnMouseMoveIn(object sender)
    {
        UIMenuListItem item = sender as UIMenuListItem;

        if (item != null)
        {
            //lz-2016.05.30 Diplomacy菜单是在游戏里面过了344剧情才开的,所有这里根据条件动态的添加和移除
            if (item.mMenuItemFlag == UIGameMenuCtrl.MenuItemFlag.Flag_Phone)
            {
                UIMenuListItem diplomacyItem = Items.Find(a => a.mMenuItemFlag == UIGameMenuCtrl.MenuItemFlag.Flag_Diplomacy);
                //lz-2016.10.10 错误 #4221 历险模式中右下角菜单中没有外交选项
                if (PeGameMgr.IsAdventure || ReputationSystem.Instance.GetActiveState((int)PeCreature.Instance.mainPlayer.GetAttribute(AttribType.DefaultPlayerID)))
                {
                    if (null == diplomacyItem)
                    {
                        this.AddItem(item, NewUIText.mMenuDiplomacy.GetString(), UIGameMenuCtrl.MenuItemFlag.Flag_Diplomacy, "listico_22_1");
                    }
                }
                else
                {
                    if (diplomacyItem != null)
                    {
                        this.DeleteItem(diplomacyItem);
                    }
                }

                //lz-2016.07.25 检测怪物图鉴
                UIMenuListItem speciesWikiItem = Items.Find(a => a.mMenuItemFlag == UIGameMenuCtrl.MenuItemFlag.Flag_SpeciesWiki);

                //lz-2016.10.18 Adventure默认开启,Story检测开启
                if (PeGameMgr.IsAdventure || (PeGameMgr.IsStory && null != StroyManager.Instance && StroyManager.Instance.enableBook))
                {
                    if (null == speciesWikiItem)
                    {
                        this.AddItem(item, NewUIText.mMenuSpeciesWiki.GetString(), UIGameMenuCtrl.MenuItemFlag.Flag_SpeciesWiki, "listico_24_1");
                    }
                }
                else
                {
                    if (speciesWikiItem != null)
                    {
                        this.DeleteItem(speciesWikiItem);
                    }
                }

                //lz-2016.07.25 检测开启播放器
                UIMenuListItem radioItem = Items.Find(a => a.mMenuItemFlag == UIGameMenuCtrl.MenuItemFlag.Flag_Radio);
                if (null != GameUI.Instance)
                {
                    if (!GameUI.Instance.mPhoneWnd.InitRadio)
                    {
                        GameUI.Instance.mPhoneWnd.InitRadioData();
                    }
                    if (GameUI.Instance.mPhoneWnd.CheckOpenRadio())
                    {
                        if (null == radioItem)
                        {
                            this.AddItem(item, NewUIText.mMenuRadio.GetString(), UIGameMenuCtrl.MenuItemFlag.Flag_Radio, "listico_25_1");
                        }
                    }
                    else
                    {
                        if (radioItem != null)
                        {
                            this.DeleteItem(radioItem);
                        }
                    }
                }
            }

            item.ItemSelectedBg.enabled = true;
            //lz-2016.09.12 播放进入菜单音效
            AudioManager.instance.Create(Vector3.zero, MouseMoveInAudioID);

            if (item != mMouseMoveInItem)
            {
                Hide_BotherPanels(item);
                if (item.IsHaveChild)
                {
                    UIMenuPanel panel = FindMenuPanel(item);
                    if (panel != null)
                    {
                        panel.Show();
                    }
                }
            }
        }
        mMouseMoveInItem = item;
        e_ItemOnMouseMoveIn.Send(eventReceiver, sender);
    }
示例#14
0
    public override void OnInspectorGUI_Propertys()
    {
        // ----------------------------------Contents--------------------------------------------------------
        DrawPartLine("Contents");

        GameObject ItemPrefab = EditorGUILayout.ObjectField("UIMeunItemPrefab", menuList.UIMeunItemPrefab, typeof(GameObject), true, GUILayout.ExpandWidth(true)) as GameObject;

        if (ItemPrefab != menuList.UIMeunItemPrefab)
        {
            menuList.UIMeunItemPrefab = ItemPrefab;
        }
        UISlicedSprite SlicedSpriteBg = EditorGUILayout.ObjectField("SlicedSpriteBg", menuList.SlicedSpriteBg, typeof(UISlicedSprite), true, GUILayout.ExpandWidth(true)) as UISlicedSprite;

        if (SlicedSpriteBg != menuList.SlicedSpriteBg)
        {
            menuList.SlicedSpriteBg = SlicedSpriteBg;
        }

        GameObject ItemsContent = EditorGUILayout.ObjectField("ItemsContent", menuList.ItemsContent, typeof(GameObject), true, GUILayout.ExpandWidth(true)) as GameObject;

        if (ItemsContent != menuList.ItemsContent)
        {
            menuList.ItemsContent = ItemsContent;
        }
        GUILayout.Space(2);
        Vector4 margin = EditorGUILayout.Vector4Field("Margin", menuList.Margin);

        if (margin != menuList.Margin)
        {
            menuList.Margin = margin;
            menuList.UpdatePanelPositon();
        }
        GUILayout.Space(7);

        UIMenuPanel root = EditorGUILayout.ObjectField("rootPanel", menuList.rootPanel, typeof(UIMenuPanel), false, GUILayout.ExpandWidth(true)) as UIMenuPanel;

        if (root != menuList.rootPanel)
        {
            menuList.rootPanel = root;
        }

        // ----------------------------------items--------------------------------------------------------
        DrawPartLine("Items");
        GUILayout.Space(2);

        Vector2 v2 = EditorGUILayout.Vector2Field("Item Size", menuList.ItemSize);

        if (v2 != menuList.ItemSize)
        {
            menuList.ItemSize = v2;
            menuList.UpdatePanelPositon();
        }
        GUILayout.Space(2);

        Vector2 panelMargin = EditorGUILayout.Vector2Field("Panel Margin", menuList.PanelMargin);

        if (panelMargin != menuList.PanelMargin)
        {
            menuList.PanelMargin = panelMargin;
            menuList.UpdatePanelPositon();
        }


        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Add Item (Input a item text)");
        string strText = EditorGUILayout.TextField("");

        GUI.backgroundColor = Color.green;
        if (GUILayout.Button(insertContent, min_buttonWidth, min_buttonHeight))
        {
            if (strText.Length == 0)
            {
                strText = "item_" + menuList.Items.Count.ToString();
            }
            menuList.AddItem(null, strText, UIGameMenuCtrl.MenuItemFlag.Flag_Null);
        }
        EditorGUILayout.EndHorizontal();



        for (int i = 0; i < menuList.panels.Count; i++)
        {
            string name = (menuList.panels[i].parent == null) ? " root" : " " + menuList.panels[i].parent.Text;
            DrawPartLine(name);
            DrawMenuPanel(menuList.panels[i].parent);
        }
    }