コード例 #1
0
    protected override int Compare(UIViewSortKind kind, object a, object b)
    {
        int result = 0;

        left  = a as IShip;
        right = b as IShip;
        switch (kind)
        {
        case UIViewSortKind.GetTime:
            result = (int)(right.GetCreatTime() - left.GetCreatTime());
            break;

        default:
            return(base.Compare(kind, left.GetBaseConfig(), right.GetBaseConfig()));
        }
        if (result == 0)
        {
            result = right.GetBaseConfig().Order - left.GetBaseConfig().Order;
        }
        if (result == 0)
        {
            result = (int)(right.GetBaseConfig().Id - left.GetBaseConfig().Id);
        }
        return(result);
    }
コード例 #2
0
    protected override int Compare(UIViewSortKind kind, object a, object b)
    {
        int result;

        if (State.GetPageIndex() == 0)
        {
            left  = a as ShopWindowVO;
            right = b as ShopWindowVO;
            return(result = (int)(left.Order - right.Order));
        }
        return(0);
    }
コード例 #3
0
    /// <summary>
    /// 更新排序视图
    /// </summary>
    private void UpdateSortView()
    {
        int sortIndex = State.GetPage().SortIndex;

        UIViewSortItem[] sortItems = State.GetPage().Sorters;

        //记录当前排序
        m_SortKind = sortIndex >= 0 && sortIndex < sortItems.Length ? sortItems[sortIndex].Kind : UIViewSortKind.None;

        //排序热键显示
        State.GetAction(UIAction.Common_Sort).State = sortIndex + 1 < sortItems.Length ? sortIndex + 1 : 0;

        //当前排序显示
        if (m_SortLabel)
        {
            m_SortLabel.text = sortIndex >= 0 && sortIndex < sortItems.Length ? sortItems[sortIndex].Label : string.Empty;
        }
    }
コード例 #4
0
    protected override int Compare(UIViewSortKind kind, object a, object b)
    {
        left  = a as ItemBase;
        right = b as ItemBase;
        if (m_CurrentItemData?.GetReference() == left.UID)
        {
            return(-1);
        }
        else if (m_CurrentItemData?.GetReference() == right.UID)
        {
            return(1);
        }
        else
        {
            if (left.Replicas.Count > 0)
            {
                for (int i = 0; i < left.Replicas.Count; i++)
                {
                    if (Parent.Data.CurrentShip.GetItem(left.Replicas[i]) != null)
                    {
                        return(-1);
                    }
                }
            }

            if (right.Replicas.Count > 0)
            {
                for (int i = 0; i < right.Replicas.Count; i++)
                {
                    if (Parent.Data.CurrentShip.GetItem(right.Replicas[i]) != null)
                    {
                        return(1);
                    }
                }
            }
        }

        return(base.Compare(kind, a, b));
    }
コード例 #5
0
 /// <summary>
 /// 取排序的多语言文字
 /// </summary>
 /// <param name="id">ID</param>
 /// <returns>文本</returns>
 private string GetSortText(UIViewSortKind id)
 {
     return(GetLocalization("package_title_" + (id + 1022)));
 }
コード例 #6
0
ファイル: UIViewState.cs プロジェクト: mengtest/RewriteFrame
    /// <summary>
    /// 初始化状态
    /// </summary>
    public void Initialize()
    {
        if (!UIConfig.HasValue)
        {
            return;
        }

        CfgEternityProxy      cfg          = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;
        GameLocalizationProxy localization = GameFacade.Instance.RetrieveProxy(ProxyName.GameLocalizationProxy) as GameLocalizationProxy;

        //主面板资源
        RootPerfabPath = UIConfig.Value.RootPrefab;
        //图标
        Icon = 0;
        if (UIConfig.Value.TitleLength > 0)
        {
            int icon = 0;
            if (int.TryParse(UIConfig.Value.Title(0), out icon))
            {
                Icon = icon;
            }
        }
        //主标题
        MainTitle = string.Empty;
        if (UIConfig.Value.TitleLength > 1)
        {
            MainTitle = localization.GetString(UIConfig.Value.Title(1));
        }
        //副标题
        SecondaryTitle = string.Empty;
        if (UIConfig.Value.TitleLength > 2)
        {
            SecondaryTitle = localization.GetString(UIConfig.Value.Title(2));
        }
        //背景资源
        BackgroundPath = UIConfig.Value.BgPic;
        //部件ID列表
        PartIDList = UIConfig.Value.GetUiModuleArray();
        //打开音效
        OpenSound = UIConfig.Value.OpenSound;
        //关闭音效
        CloseSound = UIConfig.Value.CloseSound;

        //所有页
        int count = UIConfig.Value.LabelIdLength;

        for (int i = 0; i < count; i++)
        {
            UiLabelConfig?pageCfg = cfg.GetUIPage((uint)(UIConfig.Value.LabelId(i)));
            if (!pageCfg.HasValue)
            {
                continue;
            }

            UIViewPage page = GetPage(i);

            //名称
            page.Name = !string.IsNullOrEmpty(pageCfg.Value.Name) ? localization.GetString(pageCfg.Value.Name) : string.Empty;
            //图标
            page.Icon = pageCfg.Value.Id;
            //布局
            page.ListLayoutMode = pageCfg.Value.ListType == 0 ? UIViewListLayout.Row : UIViewListLayout.Grid;
            //布局切换
            page.ListLayoutAllowChange = pageCfg.Value.ListExchange != 0;

            //排序方式列表
            List <UIViewSortItem> sorters = new List <UIViewSortItem>();
            int sortCount = pageCfg.Value.SortListLength;
            for (int j = 0; j < sortCount; j++)
            {
                UIViewSortKind kind  = (UIViewSortKind)pageCfg.Value.SortList(j);
                string         label = string.Empty;
                if (kind != UIViewSortKind.None)
                {
                    label = localization.GetString("package_title_" + (kind + 1022));
                }

                sorters.Add(new UIViewSortItem()
                {
                    Label = label, Kind = kind
                });
            }
            page.Sorters   = sorters.ToArray();
            page.SortIndex = 0;

            //分类列表
            bool isFilterMode = pageCfg.Value.AssistFunc == 1;
            List <UIViewCategory> categorys    = new List <UIViewCategory>();
            List <ItemType>       allItemTypes = new List <ItemType>();
            int length = pageCfg.Value.CategoryLength;
            for (int j = 0; j < length; j++)
            {
                UiCategoryConfig?categoryCfg = cfg.GetUICategory((uint)pageCfg.Value.Category(j));
                if (categoryCfg.HasValue)
                {
                    UIViewCategory category = new UIViewCategory();

                    if (categoryCfg.Value.Type == 1)
                    {
                        category.Label    = localization.GetString(categoryCfg.Value.LabelName);
                        category.ItemType = new ItemType[] { };
                    }
                    else
                    {
                        ItemType itemType = ItemTypeUtil.GetItemType(categoryCfg.Value.Args);

                        category.Label    = TableUtil.GetLanguageString(itemType.EnumList[itemType.EnumList.Length - 1] as System.Enum);
                        category.ItemType = new ItemType[] { itemType };

                        allItemTypes.Add(itemType);
                    }

                    category.Arguments = categoryCfg.Value.GetOtherArgsArray();

                    categorys.Add(category);
                }
            }

            //附加All
            if (isFilterMode && !string.IsNullOrEmpty(pageCfg.Value.AllLabel))
            {
                UIViewCategory category = new UIViewCategory();
                category.IsAll     = true;
                category.Label     = localization.GetString(pageCfg.Value.AllLabel);
                category.ItemType  = allItemTypes.ToArray();
                category.Arguments = new int[] { };
                categorys.Insert(0, category);
            }

            //
            page.CategoryIndex        = 0;
            page.CategoryIsFilterMode = isFilterMode;
            page.Categorys            = categorys.ToArray();
        }
    }
コード例 #7
0
    /// <summary>
    /// 按指定方式排序
    /// </summary>
    /// <param name="kind">排序方式</param>
    /// <param name="a">数据项A</param>
    /// <param name="b">数据项B</param>
    /// <returns>排序结果</returns>
    protected virtual int Compare(UIViewSortKind kind, object a, object b)
    {
        int result = 0;

        if (a is ItemBase && b is ItemBase)
        {
            ItemBase left  = a as ItemBase;
            ItemBase right = b as ItemBase;

            switch (kind)
            {
            case UIViewSortKind.Quality:
                result = right.ItemConfig.Quality - left.ItemConfig.Quality;
                break;

            case UIViewSortKind.TLevel:
                result = left.ItemConfig.Grade - right.ItemConfig.Grade;
                break;

            case UIViewSortKind.StrengthenLevel:
                result = right.Lv - left.Lv;
                break;

            case UIViewSortKind.UseLevel:
                result = right.ItemConfig.PlayerLvLimit - left.ItemConfig.PlayerLvLimit;
                break;

            case UIViewSortKind.Name:
                result = string.Compare(TableUtil.GetItemName(left.TID), TableUtil.GetItemName(right.TID));
                break;

            case UIViewSortKind.GetTime:
                result = (int)(right.CreateTime - left.CreateTime);
                break;

            case UIViewSortKind.SellPrice:
                result = (int)(right.ItemConfig.MoneyPrice - left.ItemConfig.MoneyPrice);
                break;
            }

            if (result == 0)
            {
                result = right.ItemConfig.Order - left.ItemConfig.Order;
            }
            if (result == 0)
            {
                result = (int)(right.TID - left.TID);
            }
        }
        else if (a is Item && b is Item)
        {
            Item left  = (Item)a;
            Item right = (Item)b;
            switch (kind)
            {
            case UIViewSortKind.Quality:
                result = right.Quality - left.Quality;
                break;

            case UIViewSortKind.TLevel:
                result = left.Grade - right.Grade;
                break;

            case UIViewSortKind.UseLevel:
                result = right.PlayerLvLimit - left.PlayerLvLimit;
                break;

            case UIViewSortKind.Name:
                result = string.Compare(TableUtil.GetItemName(left.Id), TableUtil.GetItemName(right.Id));
                break;

            case UIViewSortKind.SellPrice:
                result = (int)(right.MoneyPrice - left.MoneyPrice);
                break;
            }

            if (result == 0)
            {
                result = right.Order - left.Order;
            }
            if (result == 0)
            {
                result = (int)(right.Id - left.Id);
            }
        }

        return(result);
    }