Exemple #1
0
        private static void CustomSelectListCtrl_Update_ChangeController(CustomSelectListCtrl __instance)
        {
            if (EC_MakerSearch.ctrl == __instance)
            {
                return;
            }

            if (__instance.canvasGrp == null)
            {
                return;
            }

            if (!__instance.canvasGrp[0].name.Contains("win") || !__instance.canvasGrp[0].interactable || !__instance.canvasGrp[1].interactable || !__instance.canvasGrp[2].interactable)
            {
                return;
            }

            Tools.ResetSearch();

            EC_MakerSearch.ctrl = __instance;
            Tools.RememberDisvisibles();
        }
Exemple #2
0
        public static void ChangeListFilter(CustomSelectListCtrl customSelectListCtrl, ListVisibilityType visibilityType)
        {
            List <CustomSelectInfo> lstSelectInfo = (List <CustomSelectInfo>)Traverse.Create(customSelectListCtrl).Field("lstSelectInfo").GetValue();

            int count = 0;

            for (var i = 0; i < lstSelectInfo.Count; i++)
            {
                CustomSelectInfo customSelectInfo = lstSelectInfo[i];
                if (visibilityType == ListVisibilityType.All)
                {
                    customSelectListCtrl.DisvisibleItem(customSelectInfo.index, false);
                    continue;
                }

                bool hide = visibilityType != ListVisibilityType.Filtered;

                if (customSelectInfo.index >= UniversalAutoResolver.BaseSlotID)
                {
                    ResolveInfo Info = UniversalAutoResolver.TryGetResolutionInfo((ChaListDefine.CategoryNo)customSelectInfo.category, customSelectInfo.index);
                    if (Info != null)
                    {
                        if (CheckBlacklist(Info.GUID, (int)Info.CategoryNo, Info.Slot))
                        {
                            hide = visibilityType == ListVisibilityType.Filtered;
                            count++;
                        }
                    }
                }
                customSelectListCtrl.DisvisibleItem(customSelectInfo.index, hide);
            }
            ListVisibility[customSelectListCtrl] = visibilityType;

            if (count == 0 && visibilityType == ListVisibilityType.Hidden)
            {
                Logger.LogMessage("No items are hidden");
                ChangeListFilter(customSelectListCtrl, ListVisibilityType.Filtered);
            }
        }
Exemple #3
0
        private static void CustomAcsSelectKind_UpdateCustomUI_ChangeController(CustomSelectListCtrl ___listCtrl)
        {
            Tools.ResetSearch();

            EC_MakerSearch.ctrl = ___listCtrl;
        }
 private static bool ListUpdateStateNew(CustomSelectListCtrl __instance)
 {
     // Handled automatically when updating the list
     MarkListDirty(__instance);
     return(false);
 }
            private static void ListUpdate(CustomSelectListCtrl __instance)
            {
                if (!_listCache.TryGetValue(__instance, out var listData))
                {
                    return;
                }

                var scrollPosition = listData.ScrollPositionY;
                // How many items are not visible in current view
                var visibleItemCount   = listData.ItemList.Count(x => !x.disvisible);
                var offscreenItemCount = Mathf.Max(0, visibleItemCount - listData.ItemCache.Count);
                // How many items are above current view rect and not visible
                var rowsAboveViewRect  = Mathf.FloorToInt(Mathf.Clamp(scrollPosition / listData.ItemHeight, 0, offscreenItemCount));
                var itemsAboveViewRect = rowsAboveViewRect * listData.ItemsInRow;

                if (listData.LastItemsAbove == itemsAboveViewRect && !listData.IsDirty)
                {
                    return;
                }

                listData.LastItemsAbove = itemsAboveViewRect;
                listData.IsDirty        = false;

                // Store selected item to preserve selection when moving the list with mouse
                var selectedItem = listData.ItemList.Find(x => x.sic != null && x.sic.gameObject == EventSystem.current.currentSelectedGameObject);

                listData.ItemList.ForEach(x => x.sic = null);
                // Apply visible list items to actual cache items
                var count = 0;

                foreach (var item in listData.ItemList.Where(x => !x.disvisible).Skip(itemsAboveViewRect))
                {
                    if (count >= listData.ItemCache.Count)
                    {
                        break;
                    }

                    var cachedEntry = listData.ItemCache[count];

                    count++;

                    cachedEntry.info = item;
                    item.sic         = cachedEntry;

                    cachedEntry.Disable(item.disable);

                    cachedEntry.objNew.SetActiveIfDifferent(VirtualListData.IsItemNew(item));

                    var thumb = listData.GetThumbSprite(item);
                    cachedEntry.img.sprite = thumb;

                    if (ReferenceEquals(selectedItem, item))
                    {
                        EventSystem.current.SetSelectedGameObject(cachedEntry.gameObject);
                    }

                    cachedEntry.gameObject.SetActiveIfDifferent(true);
                }

                // Disable unused cache items
                if (count < listData.ItemCache.Count)
                {
                    foreach (var cacheEntry in listData.ItemCache.Skip(count))
                    {
                        cacheEntry.gameObject.SetActiveIfDifferent(false);
                    }
                }

                listData.UpdateSelection();

                // Apply top and bottom offsets to create the illusion of having all of the list items
                var topOffset = Mathf.RoundToInt(rowsAboveViewRect * listData.ItemHeight);

                listData.LayoutGroup.padding.top = listData.InitialTopPadding + topOffset;

                var totalHeight        = Mathf.CeilToInt((float)visibleItemCount / listData.ItemsInRow) * listData.ItemHeight;
                var cacheEntriesHeight = Mathf.CeilToInt((float)listData.ItemCache.Count / listData.ItemsInRow) * listData.ItemHeight;
                var trailingHeight     = totalHeight - cacheEntriesHeight - topOffset;

                listData.LayoutGroup.padding.bottom = Mathf.FloorToInt(Mathf.Max(0, trailingHeight) + listData.InitialBotPadding);

                // Needed after changing padding since it doesn't make the object dirty
                LayoutRebuilder.MarkLayoutForRebuild(listData.Content);
            }
 internal static void CustomSelectKindInitialize(CustomSelectListCtrl __instance) => ChangeListFilter(__instance, ListVisibilityType.Filtered);