Beispiel #1
0
    // todo 这个传参也很麻烦,
    public static void OpenView(ViewID key, UIEventArgs args = null)
    {
        ViewBase view = GetView(key);

        if (view != null)
        {
            view.SetOpenParam(args);

            if (BeforeOpen(view) == false)
            {
                return;
            }

            // 已加载过
            if (view.isLoaded)
            {
                InitView(view);
            }
            else
            {
                view.Load(InitView);
            }
        }
        else
        {
            GameLog.LogError("[UIModule]界面实例化失败" + key.ToString());
        }
    }
Beispiel #2
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method determines whether or not any metadata is
        /// different between the input instance and the current instance.</summary>
        ///
        /// <param name="inputViewProperty">The viewproperty to compare metadata.</param>
        ///--------------------------------------------------------------------------------
        public bool IsIdenticalMetadata(ViewProperty inputViewProperty)
        {
            if (ViewID.GetGuid() != inputViewProperty.ViewID.GetGuid())
            {
                return(false);
            }
            if (PropertyID.GetGuid() != inputViewProperty.PropertyID.GetGuid())
            {
                return(false);
            }
            if (Order.GetInt() != inputViewProperty.Order.GetInt())
            {
                return(false);
            }
            if (IsAutoUpdated.GetBool() != inputViewProperty.IsAutoUpdated.GetBool())
            {
                return(false);
            }
            if (Description.GetString() != inputViewProperty.Description.GetString())
            {
                return(false);
            }

            #region protected
            #endregion protected

            return(true);
        }
Beispiel #3
0
        public void CloseView(ViewID viewID, bool needAnim = true, bool needDestroy = false, UnityAction onComplate = null)
        {
            Debug.Log("[UIManager]CloseView :" + viewID);

            BaseView view = null;

            this._viewDic.TryGetValue(viewID, out view);
            if (view != null)
            {
                view.OnHideView(needAnim, () => {
                    view.gameObject.SetActive(false);

                    if (needDestroy)
                    {
                        this._viewDic.Remove(viewID);
                        DestroyObject(view.gameObject);
                    }

                    if (onComplate != null)
                    {
                        onComplate();
                    }
                });
            }
        }
Beispiel #4
0
    private static ViewBase GetView(ViewID key)
    {
        ViewBase view;

        if (m_viewMap.TryGetValue(key, out view))
        {
            return(view);
        }

        ViewConfig viewConfig;

        ViewDefine.ViewMapping.TryGetValue(key, out viewConfig);
        Type viewClass = viewConfig.viewClass;

        // 反射拿到实例
        view = Activator.CreateInstance(viewClass) as ViewBase;
        if (view != null)
        {
            view.key       = key;
            view.assetPath = viewConfig.path;
            view.panelName = viewConfig.name;
            return(view);
        }

        return(null);
    }
Beispiel #5
0
        /// <summary>
        /// Compares the current instance with another object of the same type.
        /// </summary>
        public int CompareTo(ViewNode other)
        {
            if (other == null)
            {
                return(1);
            }

            int compareResult = SortOrder.CompareTo(other.SortOrder);

            if (compareResult != 0)
            {
                return(compareResult);
            }

            compareResult = ViewID.CompareTo(other.ViewID);
            if (compareResult != 0)
            {
                return(compareResult);
            }

            compareResult = string.Compare(Text, other.Text, StringComparison.OrdinalIgnoreCase);
            if (compareResult != 0)
            {
                return(compareResult);
            }

            return(string.Compare(Url, other.Url, StringComparison.OrdinalIgnoreCase));
        }
Beispiel #6
0
 public static bool ViewEquals(ViewID vid, ViewID vid2)
 {
     if (vid == null || vid2 == null || GetViewHashCode(vid) != GetViewHashCode(vid2))
     {
         return(false);
     }
     return(vid.ViewName.Equals(vid2.ViewName) && SchemaEquals(vid, vid2));
 }
Beispiel #7
0
        public static int GetViewHashCode(ViewID vid)
        {
            if (!vid._hashCode.HasValue)
            {
                vid._hashCode = vid._viewName.GetHashCode();
            }

            return(GetSchemaHashCode(vid) * 19 + vid._hashCode.Value);
        }
Beispiel #8
0
    public void HideView(ViewID index)
    {
        var view = GetView(index);

        if (view)
        {
            view.Hide();
        }
    }
Beispiel #9
0
 /// <summary>
 /// 关闭弹窗
 /// </summary>
 /// <param name="viewID"></param>
 public void CloseUI(ViewID viewID)
 {
     for (int i = UIViews.Count - 1; i >= 0; i--)
     {
         if (UIViews[i].ViewID == viewID)
         {
             CloseUI(UIViews[i]);
         }
     }
 }
Beispiel #10
0
            /// <summary>
            /// Сравнить текущий объект с другим объектом такого же типа
            /// </summary>
            public int CompareTo(ViewItem other)
            {
                int subsWeight1 = Subitems.Count > 0 ? 0 : 1;
                int subsWeight2 = other.Subitems.Count > 0 ? 0 : 1;
                int comp1       = subsWeight1.CompareTo(subsWeight2);

                if (comp1 == 0)
                {
                    int comp2 = ViewID.CompareTo(other.ViewID);
                    return(comp2 == 0 ? Text.CompareTo(other.Text) : comp2);
                }
                else
                {
                    return(comp1);
                }
            }
Beispiel #11
0
    private BaseUI GetView(ViewID index, bool autoCreate = true)
    {
        int    i    = (int)index;
        BaseUI view = null;

        if (baseUI[i] == null)
        {
            view = LuckyUtils.CreatePanelFromResource <BaseUI>("Prefabs/" + mChildViews[i], transform);
            if (view)
            {
                LuckyUtils.MakeFullStretch(view.transform);
                baseUI[i] = view;
            }
            LuckyUtils.MakeIndentity(view.transform);
        }

        view = baseUI[i];

        return(view);
    }
Beispiel #12
0
    public static void CloseView(ViewID key)
    {
        ViewBase view = GetView(key);

        if (view != null)
        {
            if (view.isOpen)
            {
                view.Close();
                UINavigation.RemoveLastItem(view);
            }
            else
            {
                GameLog.LogWarning("[UIModule]界面关闭失败,已经关闭!" + key.ToString());
            }
        }
        else
        {
            GameLog.LogError("[UIModule]界面关闭失败,没有找到指定界面!" + key.ToString());
        }
    }
Beispiel #13
0
    public void ShowView(ViewID index)
    {
        if (index == ViewID.Maps)
        {
            bg.gameObject.SetActive(false);
        }
        else
        {
            bg.gameObject.SetActive(true);
        }

        var view = GetView(index);

        if (view)
        {
            view.Show();
            if (nowUI != ViewID.None)
            {
                HideView(nowUI);
            }
            nowUI = index;
        }
    }
Beispiel #14
0
 void SwitchToView(ViewID view)
 {
     if (view == ViewID.VIEW_FILE_MANAGE)
     {
         this.panelFileManager.Dock = DockStyle.Fill;
         this.panelFileManager.Show();
         this.appPanel.Hide();
         this.kryptonCheckSet1.CheckedIndex = 0;
         this.checkButtonFile.Checked = true;
         this.checkButtonApk.Checked = false;
     }
     else
     {
         this.appPanel.Dock = DockStyle.Fill;
         this.appPanel.Show();
         this.panelFileManager.Hide();
         this.kryptonCheckSet1.CheckedIndex = 1;
         this.checkButtonFile.Checked = false;
         this.checkButtonApk.Checked = true;
     }
 }
Beispiel #15
0
    public IEnumerator ShowUI(ViewID viewID)
    {
        yield return(new WaitForSeconds(1.5f));

        UIManager.Instance.ShowUI(viewID);
    }
Beispiel #16
0
        public void OpenView(ViewID viewID, OpenViewTag openTag = OpenViewTag.Nune, bool needAnim = true, UnityAction onComplate = null, params object[] args)
        {
            BaseView view = null;

            this._viewDic.TryGetValue(viewID, out view);
            if (view != null)
            {
                Debug.Log("[UIManager] OpenView: " + viewID);

                ViewConfigData viewCfgData = view.ViewData;

                switch (openTag)
                {
                case OpenViewTag.HidePrevious: {
                    if (this._navigationStack.Count > 0)
                    {
                        CloseView(this._navigationStack.Peek().viewID, false, false, null);
                    }
                }
                break;
                }

                if (viewCfgData._isNavigation)
                {
                    pushToNavigation(new ViewNavigationData()
                    {
                        viewID = viewCfgData._viewID, data = args
                    });
                }

                switch (viewCfgData._mountLayer)
                {
                case ViewMountLayer.Fixed: {
                    refreshSibling(view, this.FixedLayer);
                }
                break;

                case ViewMountLayer.Popup: {
                    refreshSibling(view, this.PopupLayer);
                }
                break;

                case ViewMountLayer.MessageBox: {
                    refreshSibling(view, this.MessageBoxLayer);
                }
                break;
                }


                view.gameObject.SetActive(true);
                view.OnShowView(needAnim, onComplate, args);
            }
            else
            {
                Debug.Log("[UIManager] loadView: " + viewID);
                AssetManager.Instance.LoadAssetAsync <BaseView>(GameConfigs.GetUIPath(UIDefine.viewPaths[viewID]), (BaseView viewPrefab) => {
                    view = GameObject.Instantiate(viewPrefab).GetComponent <BaseView>();

                    switch (view.ViewData._mountLayer)
                    {
                    case ViewMountLayer.Fixed: {
                        view.transform.SetParent(this.FixedLayer);
                    }
                    break;

                    case ViewMountLayer.Popup: {
                        view.transform.SetParent(this.PopupLayer);
                    }
                    break;

                    case ViewMountLayer.MessageBox: {
                        view.transform.SetParent(this.MessageBoxLayer);
                    }
                    break;
                    }

                    RectTransform rt = view.GetComponent <RectTransform>();
                    rt.anchorMin     = Vector2.zero;
                    rt.anchorMax     = Vector2.one;
                    rt.offsetMin     = Vector2.zero;
                    rt.offsetMax     = Vector2.one;

                    view.transform.localScale    = Vector3.one;
                    view.transform.localPosition = Vector3.zero;
                    view.gameObject.name         = viewID.ToString();
                    GameUtils.SetLayer(view.gameObject, LayerMask.NameToLayer("UI"));
                    view.Init();

                    this._viewDic.Add(viewID, view);

                    OpenView(viewID, openTag, needAnim, onComplate, args);
                });
            }
        }
Beispiel #17
0
 public void OpenView(ViewID viewID, UnityAction onComplate = null, params object[] args)
 {
     this.OpenView(viewID, OpenViewTag.Nune, true, onComplate, args);
 }
Beispiel #18
0
    /// <summary>
    /// 弹窗
    /// </summary>
    /// <param name="viewID"></param>
    public UIViewBase ShowUI(ViewID viewID)
    {
        UIViewBase ret      = null;
        ViewData   viewData = new ViewData();

        viewData.ViewID = viewID;
        string path = "";

        switch (viewID)
        {
        case ViewID.PlayWindow:
        {
            path            = "UIPrefab/PlayWindowUI/PlayUI";
            viewData.UIType = UIType.Window;
        }
        break;

        case ViewID.CompleteUI:
        {
            path            = "UIPrefab/CompleteUI/CompleteUI";
            viewData.UIType = UIType.Tip;
        }
        break;

        case ViewID.CompleteFinish:
        {
            path            = "UIPrefab/CompleteUI/CompleteFinish";
            viewData.UIType = UIType.Tip;
        }
        break;

        case ViewID.PrivateUI:
        {
            path            = "UIPrefab/PrivateUI/PrivateUI";
            viewData.UIType = UIType.Tip;
        }
        break;

        case ViewID.SettingUI:
        {
            path            = "UIPrefab/SettingUI/SettingUI";
            viewData.UIType = UIType.Tip;
        }
        break;

        case ViewID.WebViewUI:
        {
            path            = "UIPrefab/WebViewUI/WebViewUI";
            viewData.UIType = UIType.Tip;
        }
        break;

        case ViewID.PrivateFirstUI:
        {
            path            = "UIPrefab/PrivateUI/PrivateFirstUI";
            viewData.UIType = UIType.Tip;
        }
        break;

        case ViewID.WebViewAgreeUI:
        {
            path            = "UIPrefab/WebViewUI/WebViewAgreeUI";
            viewData.UIType = UIType.Tip;
        }
        break;

        default: break;
        }
        if (viewData.UIType == UIType.Tip)
        {
            for (int i = UIViews.Count - 1; i >= 0; i--)
            {
                if (UIViews[i].UIType == UIType.Tip)
                {
                    UIViews[i].Close();
                }
            }
        }
        //防止有空异常
        if (!string.IsNullOrEmpty(path))
        {
            var prefabObj = Resources.Load(path);
            if (prefabObj != null)
            {
                GameObject prefab = prefabObj as GameObject;
                GameObject obj    = GameObject.Instantiate(prefab);
                obj.name = prefab.name;
                ret      = obj.GetComponent <UIViewBase>();

                obj.transform.SetParent(showPoint);
                obj.transform.localScale    = Vector3.one;
                obj.transform.localPosition = Vector3.zero;
                obj.transform.localRotation = Quaternion.identity;

                obj.transform.SetAsLastSibling();

                RectTransform rect = obj.GetComponent <RectTransform>();
                if (rect != null)
                {
                    rect.offsetMin = Vector2.zero;
                    rect.offsetMax = Vector2.zero;
                }

                if (ret != null)
                {
                    ret.Init(viewData);
                    UIViews.Add(ret);
                }
                else
                {
                    Destroy(obj);
                }
            }
        }
        return(ret);
    }
Beispiel #19
0
 /// <summary>
 /// Инициализировать атрибуты данных
 /// </summary>
 protected void InitDataAttrs()
 {
     DataAttrs = new SortedList <string, string>();
     DataAttrs.Add("view", ViewID.ToString());
     DataAttrs.Add("cnl", AlarmCnlNum.ToString());
 }
Beispiel #20
0
 private void Awake()
 {
     baseUI = new BaseUI[mChildViews.Length];
     nowUI  = ViewID.None;
 }