Exemplo n.º 1
0
//	public void OnShow(_SourceMenuData data, AcceView acceView)//Action<MenuButtonView> clickAction)
//    {
//        this.data = data;
////        this.HandleOnClick = clickAction;
//		mAcceView = acceView;
//
//		OnSelect(false);
//    }

    public void OnInit(_SourceMenuData _data, MenuButtonViewManager manager)
    {
        data        = _data;
        menuManager = manager;

        transform.SetParent(manager.gridTransform);
        transform.localScale = Vector3.one;
        name = string.Format("Button Menu {0}", data.type);

        UpdateMenuSprite();
        OnSelect(false);
    }
    public void OnShow(_SourceMenuData data)
    {
        if (data == null)
        {
            return;
        }

        List <_SourceItemData> list = data.FindAll(x => x.isUIImageLoaded && !x.isHide);

        list.Sort((x, y) => { return(-x.createTime.CompareTo(y.createTime)); });

        OnShow(list);
    }
//
    void DownloadDefaultData(_SourceMenuData menu)
    {
        foreach (_SourceItemData item in menu.data)
        {
            DownloadDefaultData(item);
        }
        if (menu.children.Count > 0)
        {
            foreach (_SourceMenuData subMenu in menu.children)
            {
                DownloadDefaultData(subMenu);
            }
        }
    }
 void DownloadMenuUI(_SourceMenuData menu)
 {
     foreach (_SourceItemData item in menu.data)
     {
         /*DownloadItemUI(item);*/
         StartCoroutine(item.WaitForDownloadUI());
     }
     if (menu.children.Count > 0)
     {
         foreach (_SourceMenuData subMenu in menu.children)
         {
             DownloadMenuUI(subMenu);
         }
     }
 }
    /*void TransferConfigTable(_ConfigTable table, string fromDir, string toDir){
     *      foreach(_SourceMenuData menu in table.data)
     *              TransferMenuData(menu, fromDir , toDir);
     * }
     *
     * void TransferMenuData(_SourceMenuData menu, string fromDir, string toDir){
     *
     *      if(menu.children.Count > 0){
     *              foreach(_SourceMenuData subMenu in menu.children){
     *                      TransferMenuData(subMenu, fromDir, toDir);
     *              }
     *      }else{
     *              foreach(_SourceItemData item in menu.data){
     *                      TransferItemData(item, fromDir, toDir);
     *              }
     *      }
     * }
     *
     * void TransferItemData(_SourceItemData item, string fromDir, string toDir){
     *
     * //		string path_0 = Path.Combine(Application.dataPath,  "/../LocalDatabase/UI/"+ item.title + ".png");
     * //		if(File.Exists(path_0)){
     * //			Debug.Log("Application.dataPath is Exists !");
     * //		}
     * //
     * //		string path_1 =  "file://" + Application.dataPath + "/../LocalDatabase/UI/"+ item.title + ".png";
     * //		if(File.Exists(path_1)){
     * //			Debug.Log("File:// Path is Exists !");
     * //		}
     *
     *      StartCoroutine(new WWWProxy(){
     * //			url = fromDir + "/UI/" + item.title + ".png",
     *              url =  "file://" + Application.dataPath + "/../LocalDatabase/UI/"+ item.title + ".png",
     *              feedback = delegate(WWW www){
     *
     *                      _InternalDataCodec.SaveTexture(item.UIImageLocalPath, www.texture, true);
     * //				item.UIImageLocalPath = toDir + "/UI/" + item.title + ".png";
     * //				item.isUIImageLoaded = true;
     *
     *                      SaveDefaultConfigTable();
     *                      Debug.Log("Transfer UI :" + item.title);
     *              }}.WaitForFinished());
     *
     *      StartCoroutine(new WWWProxy(){
     * //			url = fromDir + "/Asset/" + item.title + ".unity3d",
     *              url =   "file://" + Application.dataPath + "/../LocalDatabase/Asset/"+ item.title + ".unity3d",
     *              feedback = delegate(WWW www){
     *
     *                      _InternalDataCodec.SaveBytes(item.DecorationLocalPath, www.bytes);
     *                      //item.DecorationLocalPath = toDir + "/Asset/" + item.title + ".unity3d";
     *                      SaveDefaultConfigTable();
     *                      Debug.Log("Transfer Assets : " + item.title);
     *              }}.WaitForFinished());
     *
     *      / *
     #if UNITY_EDITOR
     *
     *
     *      _InternalDataCodec.TransferBytes(fromDir + "/Asset/" + item.title + ".unity3d", toDir + "/Asset/" + item.title + ".unity3d");
     * //		item.DecorationLocalPath = toDir + "/Asset/" + item.title + ".unity3d";
     *      SaveDefaultConfigTable();
     *
     #else
     *
     *      StartCoroutine(new WWWProxy(){
     *              url = fromDir + "/Asset/" + item.title + ".unity3d",
     *              feedback = delegate(WWW www){
     *
     *                      _InternalDataCodec.SaveBytes(toDir + "/Asset/" + item.title + ".unity3d", www.bytes);
     *                      //item.DecorationLocalPath = toDir + "/Asset/" + item.title + ".unity3d";
     *                      SaveDefaultConfigTable();
     * //				Debug.Log("Transfer Assets : " + item.title);
     *              }}.WaitForFinished());
     *
     #endif
     *
     * /
     * }*/

    void DeletaMenuData(_SourceMenuData menu)
    {
        foreach (_SourceItemData item in menu.data)
        {
            DeletaItemData(item);
        }
        menu.data.Clear();
        if (menu.children.Count > 0)
        {
            foreach (_SourceMenuData subMenu in menu.children)
            {
                DeletaMenuData(subMenu);
            }
            menu.children.Clear();
        }
    }
    void CompareMenuData(List <_SourceMenuData> sourceMenus, List <_SourceMenuData> destMenus)
    {
        if (sourceMenus == null || destMenus == null || (sourceMenus.Count == 0 && destMenus.Count == 0))
        {
            return;
        }

        foreach (_SourceMenuData menu in destMenus.FindAll(x => !sourceMenus.Contains(x)))
        {
            DeletaMenuData(menu);
            destMenus.Remove(menu);

            SaveLocalConfigTable();
        }

        foreach (_SourceMenuData menu in sourceMenus)
        {
//			Debug.Log(menu.type + "-------");
            _SourceMenuData dest = destMenus.Find(x => menu.Equals(x));
//			Debug.Log("find menu.equals(x)" + dest.type);
            //Debug.Log (dest.type + ", " + menu.type);
//			List<_SourceMenuData> dests = destMenus.FindAll(x => menu.Equals(x));

            if (dest == null)
            {
//				int index = destMenus.IndexOf(menu);

                DownloadMenuUI(menu);
                destMenus.Add(menu);

//				SaveLocalConfigTable();
            }
            else
            {
                CompareItemData(menu.data, dest.data);                // destMenus[index]);
                if (menu.children.Count > 0)
                {
                    CompareMenuData(menu.children, dest.children);
                }

//				SaveLocalConfigTable();
            }
        }
    }
Exemplo n.º 7
0
//  public void HandleOnColliderTrigging(string type){
//      itemManager.OnShow(menuManager.HandleOnColliderTrigging(type));
//  }

    public void HandleOnMenuClicked(_SourceMenuData data)
    {
        itemManager.OnShow(data);

/*		_UIController.Instance.HandleOnAcceMenuButClicked(data.type);*/
    }