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(); }
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; } }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }