コード例 #1
0
 static Dialog_ThingFilter()
 {
     baseFilter = new ThingFilter();
     baseFilter.SetAllowAll(null);
     baseFilter.DisplayRootCategory          = ThingCategoryNodeDatabase.RootNode;
     baseFilter.allowedHitPointsConfigurable = false;
     baseFilter.allowedQualitiesConfigurable = false;
 }
コード例 #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();
        }
コード例 #3
0
 public OutputLink(Building_BeltSplitter parent, IntVec3 pos)
 {
     this.parent   = parent;
     link          = null;
     this.position = pos;
     // TODO: any way to make filter null unless it's actually needed?
     //   maybe not?
     filter = new ThingFilter();
     filter.SetAllowAll(null);
 }
コード例 #4
0
ファイル: SettingsUI.cs プロジェクト: jptrrs/BurnItForFuel
        public static void DoThingFilterConfigWindow(Rect rect, ref Vector2 scrollPosition, ref ThingFilter filter, ThingFilter parentFilter = null, ThingFilter defaultFilter = null, int openMask = 1)
        {
            Widgets.DrawMenuSection(rect);
            Text.Font = GameFont.Tiny;
            float num   = rect.width - 2f;
            Rect  rect2 = new Rect(rect.x + 1f, rect.y + 1f, num / 2f, buttonHeight);

            if (Widgets.ButtonText(rect2, "ClearAll".Translate(), true, false, true))
            {
                filter.SetDisallowAll(null, null);
                SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null);
            }
            Rect rect3 = new Rect(rect2.xMax + 1f, rect2.y, rect.xMax - 1f - (rect2.xMax + 1f), buttonHeight);

            if (Widgets.ButtonText(rect3, "AllowAll".Translate(), true, false, true))
            {
                filter.SetAllowAll(parentFilter);
                SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null);
            }
            Text.Font = GameFont.Small;
            rect.yMin = rect2.yMax;
            TreeNode_ThingCategory node = ThingCategoryNodeDatabase.RootNode;

            if (parentFilter != null)
            {
                node = parentFilter.DisplayRootCategory;
            }
            Rect viewRect   = new Rect(0f, 0f, rect.width - 17f, viewHeight);
            Rect scrollrect = new Rect(rect.x, rect.y, rect.width - 1f, rect.height - buttonHeight - 1f);

            Widgets.BeginScrollView(scrollrect, ref scrollPosition, viewRect, true);
            float num2  = 2f;
            float num3  = num2;
            Rect  rect4 = new Rect(0f, num2, viewRect.width, 9999f);
            Listing_TreeThingFilter listing_TreeThingFilter = new Listing_TreeThingFilter(filter, parentFilter, null, null, null);

            listing_TreeThingFilter.Begin(rect4);
            listing_TreeThingFilter.DoCategoryChildren(node, 0, openMask, null, true);
            listing_TreeThingFilter.End();
            if (Event.current.type == EventType.Layout)
            {
                viewHeight = num3 + listing_TreeThingFilter.CurHeight + 90f;
            }
            Widgets.EndScrollView();
            Rect buttonRect = new Rect(rect.x + 1f, rect.y + 1f, num, buttonHeight);

            buttonRect.height   = 24f;
            buttonRect.position = new Vector2(buttonRect.position.x, rect.yMax - buttonHeight - 1f);
            bool clicked = Widgets.ButtonText(buttonRect, "Reset");

            if (clicked && defaultFilter != null)
            {
                filter = defaultFilter;
            }
        }
コード例 #5
0
        public Trigger_Threshold(ManagerJob_Foraging job) : base(job.manager)
        {
            Op = Ops.LowerThan;
            MaxUpperThreshold = DefaultMaxUpperThreshold;
            TargetCount       = DefaultCount;
            ThresholdFilter   = new ThingFilter(job.Notify_ThresholdFilterChanged);
            ThresholdFilter.SetDisallowAll();

            ParentFilter = new ThingFilter();
            ParentFilter.SetAllowAll(null);
        }
コード例 #6
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, List <ThingDef> suppressSmallVolumeTags = null)
        {
            Widgets.DrawMenuSection(rect);
            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()))
            {
                filter.SetDisallowAll(forceHiddenDefs, forceHiddenFilters);
            }
            Rect rect3 = new Rect(rect2.xMax + 1f, rect2.y, rect.xMax - 1f - (rect2.xMax + 1f), 24f);

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

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

            DrawHitPointsFilterConfig(ref num2, viewRect.width, filter);
            DrawQualityFilterConfig(ref num2, viewRect.width, filter);
            DrawMarketValueFilterConfig(ref num2, viewRect.width, filter);
            float num3  = num2;
            Rect  rect4 = new Rect(0f, num2, viewRect.width, 9999f);
            Listing_TreeThingFilter listing_TreeThingFilter = new Listing_TreeThingFilter(filter, parentFilter, forceHiddenDefs, forceHiddenFilters, suppressSmallVolumeTags);

            listing_TreeThingFilter.Begin(rect4);
            TreeNode_ThingCategory node = ThingCategoryNodeDatabase.RootNode;

            if (parentFilter != null)
            {
                node = parentFilter.DisplayRootCategory;
            }
            listing_TreeThingFilter.DoCategoryChildren(node, 0, openMask, true);
            listing_TreeThingFilter.End();
            if (Event.current.type == EventType.Layout)
            {
                viewHeight = num3 + listing_TreeThingFilter.CurHeight + 90f;
            }
            Widgets.EndScrollView();
        }
コード例 #7
0
 public static void DoThingFilterConfigWindow(Rect rect, ref Vector2 scrollPosition, ThingFilter filter, ThingFilter parentFilter = null, int openMask = 1)
 {
     Widgets.DrawMenuSection(rect);
     Text.Font = GameFont.Tiny;
     var num = rect.width - 2f;
     var rect2 = new Rect(rect.x + 1f, rect.y + 1f, num / 2f, 24f);
     if (Widgets.ButtonText(rect2, "ClearAll".Translate()))
     {
         filter.SetDisallowAll();
     }
     var rect3 = new Rect(rect2.xMax + 1f, rect2.y, num / 2f - 1f, 24f);
     if (Widgets.ButtonText(rect3, "AllowAll".Translate()))
     {
         filter.SetAllowAll(parentFilter);
     }
     Text.Font = GameFont.Small;
     rect.yMin = rect2.yMax;
     var viewRect = new Rect(0f, 0f, rect.width - 16f, viewHeight);
     Widgets.BeginScrollView(rect, ref scrollPosition, viewRect);
     var num2 = 0f;
     num2 += 2f;
     DrawHitPointsFilterConfig(ref num2, viewRect.width, filter);
     DrawQualityFilterConfig(ref num2, viewRect.width, filter);
     var num3 = num2;
     var rect4 = new Rect(0f, num2, 9999f, 9999f);
     var listing_TreeThingFilter = new Listing_TreeThingFilter(rect4, filter, parentFilter);
     var node = ThingCategoryNodeDatabase.RootNode;
     if (parentFilter != null)
     {
         if (parentFilter.DisplayRootCategory == null)
         {
             parentFilter.RecalculateDisplayRootCategory();
         }
         node = parentFilter.DisplayRootCategory;
     }
     listing_TreeThingFilter.DoCategoryChildren(node, 0, openMask, true);
     listing_TreeThingFilter.End();
     if (Event.current.type == EventType.Layout)
     {
         viewHeight = num3 + listing_TreeThingFilter.CurHeight + 90f;
     }
     Widgets.EndScrollView();
 }
コード例 #8
0
 public void DoThingFilterConfigWindow(Rect rect, ref Vector2 scrollPosition, ThingFilter filter, ThingFilter parentFilter = null, int openMask = 1)
 {
     Widgets.DrawMenuSection(rect);
     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()))
     {
         filter.SetDisallowAll();
     }
     Rect rect3 = new Rect(rect2.xMax + 1f, rect2.y, num / 2f, 24f);
     if (Widgets.TextButton(rect3, "AllowAll".Translate()))
     {
         filter.SetAllowAll(parentFilter);
     }
     Text.Font = GameFont.Small;
     rect.yMin = rect2.yMax;
     Rect viewRect = new Rect(0f, 0f, rect.width - 16f, viewHeight);
     Widgets.BeginScrollView(rect, ref scrollPosition, viewRect);
     float num2 = 0f;
     num2 += 2f;
     DrawHitPointsFilterConfig(ref num2, viewRect.width, filter);
     DrawQualityFilterConfig(ref num2, viewRect.width, filter);
     float num3 = num2;
     Rect rect4 = new Rect(0f, num2, 9999f, 9999f);
     Listing_TreeThingFilter listingTreeThingFilter = 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;
     }
     listingTreeThingFilter.DoCategoryChildren(node, 0, openMask, true);
     listingTreeThingFilter.End();
     viewHeight = num3 + listingTreeThingFilter.CurHeight + 90f;
     Log.Message(viewHeight.ToString(CultureInfo.InvariantCulture));
     Widgets.EndScrollView();
 }
コード例 #9
0
        private void InitMenuFilter(ThingFilter globalFilter)
        {
            menuFilter = new ThingFilter();
            menuFilter.SetAllowAll(globalFilter);
            foreach (var def in menuFilter.AllowedThingDefs.ToArray())
            {
                if (def.ingestible?.joy <= 0)
                {
                    var preferability = def.ingestible.preferability;
                    if (preferability == FoodPreferability.DesperateOnly ||
                        preferability == FoodPreferability.DesperateOnlyForHumanlikes ||
                        preferability == FoodPreferability.RawBad)
                    {
                        menuFilter.SetAllow(def, false);
                    }

                    if (preferability == FoodPreferability.Undefined)
                    {
                        Log.Message($"{def.LabelCap} has preferability undefined");
                    }
                }
            }
        }
コード例 #10
0
        public ManagerJob_Fishing(Manager manager) : base(manager)
        {
            var thingFilter = new ThingFilter(Notify_ThresholdFilterChanged);

            thingFilter.SetDisallowAll();
            var parentFilter = new ThingFilter();

            parentFilter.SetAllowAll(null);
            Trigger = new Trigger_Threshold(this.manager)
            {
                Op = Trigger_Threshold.Ops.LowerThan,
                MaxUpperThreshold = Trigger_Threshold.DefaultMaxUpperThreshold,
                TargetCount       = Trigger_Threshold.DefaultCount,
                ThresholdFilter   = thingFilter,
                ParentFilter      = parentFilter,
                countAllOnMap     = true
            };
            History = new History(new[] { I18n.HistoryStock, I18n.HistoryDesignated }, new[] { Color.white, Color.grey });
            if (Scribe.mode == LoadSaveMode.Inactive)
            {
                RefreshAllowedFish();
            }
        }
コード例 #11
0
        public static void DoThingFilterConfigWindowHeader(ref Rect rect, ref Vector2 scrollPosition, ThingFilter filter, ThingFilter parentFilter = null, int openMask = 1, IEnumerable <ThingDef> forceHiddenDefs = null, IEnumerable <SpecialThingFilterDef> forceHiddenFilters = null, List <ThingDef> suppressSmallVolumeTags = null)
        {
            bool showSearch = showSearchCount-- > 0 && searchOptions.Count != 0;

            showSearchCount = Math.Max(0, showSearchCount);

            if (showSearch)
            {
                /*      Layout
                 *                   buttonSpacing    2x buttonSpacing                                                             buttonsInset
                 *                     |                |                                                                           |        |
                 *                   |<>|            |<--->|                                                                      |<>|       |
                 *                                                                                                                           |
                 *   +---------------------------------------------------------------------------------------------------------------+   -   |
                 *   |                                                                                                               |   o---+
                 *   |  +------------+--+------------+-----+----------------------------------------------------------------------+  |   -
                 *   |  |            |  |            |     |                                                                      |  |   ^
                 *   |  |   CLEAR    |  |   ALLOW    |     |                                                                      |  |   |
                 *   |  |            |  |            |     |              SEARCH BOX                                              |  |   |- buttonSize
                 *   |  |    ALL     |  |    ALL     |     |                                                                      |  |   |
                 *   |  |            |  |            |     |                                                                      |  |   v
                 *   |  +------------+--+------------+-----+------------ headRect ------------------------------------------------+  |   -
                 *   |                                                                                                               |
                 *
                 *
                 *      |<------ restWidth --------->|     |<--------------------------- searchWidth ---------------------------->|
                 *
                 *
                 *      |<--------->|   |<---------->|
                 *              |             |
                 *              clearAllowWidth
                 *              (clamped to min
                 *               buttonSize+2*2)
                 */


                var headRect = new Rect(rect.x + buttonsInset, rect.y + buttonsInset, rect.width - (2 * buttonsInset), buttonSize);
                Text.Font = GameFont.Tiny;
                var restWidth       = headRect.width * (1 - Settings.SearchWidth) - 3 * buttonSpacing;
                var clearAllowWidth = Math.Max(buttonSize, restWidth / 2f);


                Text.Font = GameFont.Tiny;
                var clear = "ClearAll".Translate();
                var allow = "AllowAll".Translate();

                // check min width "clear"/"allow" texts would need
                var minWidth = new[] { clear, allow }.Max(c => Text.CurFontStyle.CalcSize(new GUIContent(c)).x);

                Func <Rect, string, object, bool> drawButton;

                if (minWidth + 4f > clearAllowWidth)
                {
                    // use icons
                    drawButton = (r, t, o) => ExtraWidgets.ButtonImage(r, (Texture2D)o, true, new TipSignal {
                        text = t
                    }, new Rect(r.x + (r.width - buttonSize) / 2f, r.y, buttonSize, buttonSize));
                }
                else
                {
                    // use text buttons
                    drawButton = (r, t, _) => Widgets.ButtonText(r, t, true, false, true);
                }

                Rect rect2 = new Rect(headRect.x, headRect.y, clearAllowWidth, buttonSize);
                if (drawButton(rect2, clear, Widgets.CheckboxOffTex))
                {
                    filter.SetDisallowAll(forceHiddenDefs, forceHiddenFilters);
                }
                Rect rect3 = new Rect(headRect.x + clearAllowWidth + buttonSpacing, headRect.y, clearAllowWidth, buttonSize);
                if (drawButton(rect3, allow, Widgets.CheckboxOnTex))
                {
                    filter.SetAllowAll(parentFilter);
                }

                var searchWidth = headRect.width - (2 * clearAllowWidth + 3 * buttonSpacing);

                Rect searchRect = new Rect(headRect.xMax - searchWidth, headRect.y, searchWidth, buttonSize);

                var options = searchOptions.Dequeue();
                DoSearchBlock(searchRect, options.Term, options.Watermark);
                ThingFilter_InjectFilter.Projections.Enqueue(options.Term.FilterNodes);

                rect.yMin = searchRect.yMax;
            }
            else
            {
                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);
                }
                Rect rect3 = new Rect(rect2.xMax + 1f, rect2.y, rect.xMax - 1f - (rect2.xMax + 1f), 24f);
                if (Widgets.ButtonText(rect3, "AllowAll".Translate(), true, false, true))
                {
                    filter.SetAllowAll(parentFilter);
                }
                Text.Font = GameFont.Small;
                rect.yMin = rect2.yMax + 1;
            }
        }
コード例 #12
0
        public void DoThingFilterConfigWindow( Rect canvas, ref Vector2 scrollPosition, ThingFilter filter,
                                               ThingFilter parentFilter = null, int openMask = 1,
                                               bool buttonsAtBottom = false )
        {
            // respect your bounds!
            GUI.BeginGroup( canvas );
            canvas = canvas.AtZero();

            // set up buttons
            Text.Font = GameFont.Tiny;
            float width = canvas.width - 2f;
            var clearButtonRect = new Rect( canvas.x + 1f, canvas.y + 1f, width / 2f, 24f );
            var allButtonRect = new Rect( clearButtonRect.xMax + 1f, clearButtonRect.y, width / 2f, 24f );

            // offset canvas position for buttons.
            if ( buttonsAtBottom )
            {
                clearButtonRect.y = canvas.height - clearButtonRect.height;
                allButtonRect.y = canvas.height - clearButtonRect.height;
                canvas.yMax -= clearButtonRect.height;
            }
            else
            {
                canvas.yMin = clearButtonRect.height;
            }

            // draw buttons + logic
            if ( Widgets.ButtonTextSubtle( clearButtonRect, "ClearAll".Translate() ) )
            {
                filter.SetDisallowAll();
            }
            if ( Widgets.ButtonTextSubtle( allButtonRect, "AllowAll".Translate() ) )
            {
                filter.SetAllowAll( parentFilter );
            }
            Text.Font = GameFont.Small;

            // do list
            var curY = 2f;
            var viewRect = new Rect( 0f, 0f, canvas.width - 16f, viewHeight );

            // scrollview
            Widgets.BeginScrollView( canvas, ref scrollPosition, viewRect );

            // slider(s)
            DrawHitPointsFilterConfig( ref curY, viewRect.width, filter );
            DrawQualityFilterConfig( ref curY, viewRect.width, filter );

            // main listing
            var listingRect = new Rect( 0f, curY, viewRect.width, 9999f );
            var listingTreeThingFilter = new Listing_TreeThingFilter( listingRect, filter, parentFilter, null, null );
            TreeNode_ThingCategory node = ThingCategoryNodeDatabase.RootNode;
            if ( parentFilter != null )
            {
                if ( parentFilter.DisplayRootCategory == null )
                {
                    parentFilter.RecalculateDisplayRootCategory();
                }
                node = parentFilter.DisplayRootCategory;
            }

            // draw the actual thing
            listingTreeThingFilter.DoCategoryChildren( node, 0, openMask, true );
            listingTreeThingFilter.End();

            // update height.
            viewHeight = curY + listingTreeThingFilter.CurHeight;
            Widgets.EndScrollView();
            GUI.EndGroup();
        }
コード例 #13
0
        public void DoThingFilterConfigWindow(Rect canvas, ref Vector2 scrollPosition, ThingFilter filter,
                                              ThingFilter parentFilter = null, int openMask = 1,
                                              bool buttonsAtBottom     = false)
        {
            // respect your bounds!
            GUI.BeginGroup(canvas);
            canvas = canvas.AtZero();

            // set up buttons
            Text.Font = GameFont.Tiny;
            float width           = canvas.width - 2f;
            var   clearButtonRect = new Rect(canvas.x + 1f, canvas.y + 1f, width / 2f, 24f);
            var   allButtonRect   = new Rect(clearButtonRect.xMax + 1f, clearButtonRect.y, width / 2f, 24f);

            // offset canvas position for buttons.
            if (buttonsAtBottom)
            {
                clearButtonRect.y = canvas.height - clearButtonRect.height;
                allButtonRect.y   = canvas.height - clearButtonRect.height;
                canvas.yMax      -= clearButtonRect.height;
            }
            else
            {
                canvas.yMin = clearButtonRect.height;
            }

            // draw buttons + logic
            if (Widgets.ButtonTextSubtle(clearButtonRect, "ClearAll".Translate()))
            {
                filter.SetDisallowAll();
            }
            if (Widgets.ButtonTextSubtle(allButtonRect, "AllowAll".Translate()))
            {
                filter.SetAllowAll(parentFilter);
            }
            Text.Font = GameFont.Small;

            // do list
            var curY     = 2f;
            var viewRect = new Rect(0f, 0f, canvas.width - ScrollbarWidth, viewHeight);

            // scrollview
            Widgets.BeginScrollView(canvas, ref scrollPosition, viewRect);

            // slider(s)
            DrawHitPointsFilterConfig(ref curY, viewRect.width, filter);
            DrawQualityFilterConfig(ref curY, viewRect.width, filter);

            // main listing
            var listingRect            = new Rect(0f, curY, viewRect.width, 9999f);
            var listingTreeThingFilter = new Listing_TreeThingFilter(filter, parentFilter, null, null, null);

            listingTreeThingFilter.Begin(listingRect);
            TreeNode_ThingCategory node = ThingCategoryNodeDatabase.RootNode;

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

            // draw the actual thing
            listingTreeThingFilter.DoCategoryChildren(node, 0, openMask, Find.CurrentMap, true);
            listingTreeThingFilter.End();

            // update height.
            viewHeight = curY + listingTreeThingFilter.CurHeight;
            Widgets.EndScrollView();
            GUI.EndGroup();
        }
コード例 #14
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();
        }
コード例 #15
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();
        }