Exemplo n.º 1
0
        public static void DoThingFilterConfigWindow(Rect rect, ref Vector2 scrollPosition, ThingFilter filter, ThingFilter parentFilter = null, int openMask = 1, IEnumerable <ThingDef> forceHiddenDefs = null, IEnumerable <SpecialThingFilterDef> forceHiddenFilters = null, string filterText = null)
        {
            Widgets.DrawMenuSection(rect, true);
            Text.Font = GameFont.Tiny;
            float num   = rect.width - 2f;
            Rect  rect2 = new Rect(rect.x + 1f, rect.y + 1f, num / 2f, 24f);

            if (Widgets.ButtonText(rect2, "ClearAll".Translate(), true, false, true))
            {
                filter.SetDisallowAll(forceHiddenDefs, forceHiddenFilters);
            }
            if (Widgets.ButtonText(new Rect(rect2.xMax + 1f, rect2.y, num / 2f, 24f), "AllowAll".Translate(), true, false, true))
            {
                filter.SetAllowAll(parentFilter);
            }
            Text.Font = GameFont.Small;
            rect.yMin = rect2.yMax;
            Rect viewRect = new Rect(0f, 0f, rect.width - 16f, HelperThingFilterUI.viewHeight);

            Widgets.BeginScrollView(rect, ref scrollPosition, viewRect);
            float num2 = 2f;

            HelperThingFilterUI.DrawHitPointsFilterConfig(ref num2, viewRect.width, filter);
            HelperThingFilterUI.DrawQualityFilterConfig(ref num2, viewRect.width, filter);
            float num3 = num2;
            Listing_TreeThingFilter listing_TreeThingFilter = new Listing_TreeThingFilter(new Rect(0f, num2, viewRect.width, 9999f), filter, parentFilter, forceHiddenDefs, forceHiddenFilters);
            TreeNode_ThingCategory  treeNode_ThingCategory  = ThingCategoryNodeDatabase.RootNode;

            if (parentFilter != null)
            {
                if (parentFilter.DisplayRootCategory == null)
                {
                    parentFilter.RecalculateDisplayRootCategory();
                }
                treeNode_ThingCategory = parentFilter.DisplayRootCategory;
            }
            if (filterText != null && filterText.Length > 0)
            {
                TreeNode_ThingCategory treeNode_ThingCategory2 = new TreeNode_ThingCategory(new ThingCategoryDef());
                from td in treeNode_ThingCategory.catDef.DescendantThingDefs
                where td.label.ToLower().Contains(filterText.ToLower())
                select td;
                IEnumerable <ThingDef> arg_1D5_0 = treeNode_ThingCategory.catDef.DescendantThingDefs;
                Func <ThingDef, bool> < > 9__1;
                Func <ThingDef, bool> arg_1D5_1;
                if ((arg_1D5_1 = < > 9__1) == null)
                {
                    arg_1D5_1 = (< > 9__1 = ((ThingDef td) => td.label.ToLower().Contains(filterText.ToLower())));
                }
                foreach (ThingDef current in arg_1D5_0.Where(arg_1D5_1))
                {
                    treeNode_ThingCategory2.catDef.childThingDefs.Add(current);
                }
                treeNode_ThingCategory = treeNode_ThingCategory2;
            }
            listing_TreeThingFilter.DoCategoryChildren(treeNode_ThingCategory, 0, openMask, true);
            listing_TreeThingFilter.End();
            if (Event.current.type == EventType.Layout)
            {
                HelperThingFilterUI.viewHeight = num3 + listing_TreeThingFilter.CurHeight + 90f;
            }
            Widgets.EndScrollView();
        }
Exemplo n.º 2
0
        public static void DoThingFilterConfigWindow(Rect rect, ref Vector2 scrollPosition, ThingFilter filter, ThingFilter parentFilter = null, int openMask = 1, string filterText = null)
        {
            Widgets.DrawMenuSection(rect, true);
            Text.Font = GameFont.Tiny;
            float num   = rect.width - 2f;
            Rect  rect2 = new Rect(rect.x + 1f, rect.y + 1f, num / 2f, 24f);

            if (Widgets.TextButton(rect2, "ClearAll".Translate(), true, false))
            {
                filter.SetDisallowAll();
            }
            Rect rect3 = new Rect(rect2.xMax + 1f, rect2.y, num / 2f, 24f);

            if (Widgets.TextButton(rect3, "AllowAll".Translate(), true, false))
            {
                filter.SetAllowAll(parentFilter);
            }
            Text.Font = GameFont.Small;
            rect.yMin = rect2.yMax;
            Rect viewRect = new Rect(0f, 0f, rect.width - 16f, HelperThingFilterUI.viewHeight);

            Widgets.BeginScrollView(rect, ref scrollPosition, viewRect);
            float num2 = 0f;

            num2 += 2f;
            HelperThingFilterUI.DrawHitPointsFilterConfig(ref num2, viewRect.width, filter);
            HelperThingFilterUI.DrawQualityFilterConfig(ref num2, viewRect.width, filter);
            float num3  = num2;
            Rect  rect4 = new Rect(0f, num2, 9999f, 9999f);
            Listing_TreeThingFilter listing_TreeThingFilter = new Listing_TreeThingFilter(rect4, filter, parentFilter, 210f, true);
            TreeNode_ThingCategory  node = ThingCategoryNodeDatabase.RootNode;

            if (parentFilter != null)
            {
                if (parentFilter.DisplayRootCategory == null)
                {
                    parentFilter.RecalculateDisplayRootCategory();
                }
                node = parentFilter.DisplayRootCategory;
            }

            if (filterText != null && filterText.Length > 2)
            {
                var rootNode = new TreeNode_ThingCategory(new ThingCategoryDef());

                node.catDef.DescendantThingDefs.Where(td => td.label.ToLower().Contains(filterText.ToLower()));

                foreach (ThingDef currentThing in node.catDef.DescendantThingDefs.Where(td => td.label.ToLower().Contains(filterText.ToLower())))
                {
                    rootNode.catDef.childThingDefs.Add(currentThing);
                }

                node = rootNode;
            }

            listing_TreeThingFilter.DoCategoryChildren(node, 0, openMask, true);
            listing_TreeThingFilter.End();
            if (Event.current.type == EventType.Layout)
            {
                HelperThingFilterUI.viewHeight = num3 + listing_TreeThingFilter.CurHeight + 90f;
            }
            Widgets.EndScrollView();
        }