diff --git a/Source/ProjectRimFactory/SAL3/Things/ITab_RecipeHolder.cs b/Source/ProjectRimFactory/SAL3/Things/ITab_RecipeHolder.cs index 618bd5dd..14163279 100644 --- a/Source/ProjectRimFactory/SAL3/Things/ITab_RecipeHolder.cs +++ b/Source/ProjectRimFactory/SAL3/Things/ITab_RecipeHolder.cs @@ -1,6 +1,7 @@ using RimWorld; using System.Collections.Generic; using UnityEngine; +using UnityEngine.UIElements; using Verse; namespace ProjectRimFactory.SAL3.Things @@ -85,12 +86,14 @@ public ITab_RecipeHolder() private bool showSaved = true; private bool showLearnable = true; private bool showQuered = true; + private string searchText = ""; - private bool ShouldDrawRow(RecipeDef recipe, ref float curY, float ViewRecthight, float scrollY) + private bool ShouldDrawRow(RecipeDef recipe, ref float curY, float ViewRecthight, float scrollY, string search) { if (!showLearnable && Recipes[recipe] == enum_RecipeStatus.Learnable) return false; if (!showQuered && Recipes[recipe] == enum_RecipeStatus.Quered) return false; if (!showSaved && Recipes[recipe] == enum_RecipeStatus.Saved) return false; + if (search != "" && !recipe.label.ToLower().Contains(search.ToLower())) return false; //The item is above the view (including a safty margin of one item) if ((curY + ROW_HIGHT - scrollY) < 0) @@ -111,7 +114,7 @@ private bool ShouldDrawRow(RecipeDef recipe, ref float curY, float ViewRecthight return false; } - + protected override void FillTab() { RefreshRecipeList(); @@ -140,6 +143,14 @@ protected override void FillTab() rect = list.GetRect(10); currY += 10; Widgets.DrawLineHorizontal(0, rect.y, rect.width); + rect = list.GetRect(20); + currY += 20; + rect.width -= 30 + 16 + 20 + 100; + rect.x += 20; + searchText = Widgets.TextField(rect, searchText); + rect.x -= 20; + rect.width = 20; + GUI.DrawTexture(rect, TexButton.Search); var outRect = new Rect(5f, currY + 5, WinSize.x - 30, WinSize.y - currY - 30); @@ -151,7 +162,7 @@ protected override void FillTab() foreach (RecipeDef recipe in Recipes.Keys) { - if (!ShouldDrawRow(recipe, ref currY, outRect.height, scrollPos.y)) continue; + if (!ShouldDrawRow(recipe, ref currY, outRect.height, scrollPos.y, searchText)) continue; DrawRecipeRow(recipe, ref currY, viewRect.width);