From deba200b24ed60a22d1af171ecb3c9cfc8de659b Mon Sep 17 00:00:00 2001 From: Sn1p3rr3c0n Date: Sat, 23 Jan 2021 14:14:34 +0100 Subject: [PATCH] #292 Added UI Performence Improvements 2 --- .../SAL3/Things/ITab_RecipeHolder.cs | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/Source/ProjectRimFactory/SAL3/Things/ITab_RecipeHolder.cs b/Source/ProjectRimFactory/SAL3/Things/ITab_RecipeHolder.cs index ae47608e..f668ed62 100644 --- a/Source/ProjectRimFactory/SAL3/Things/ITab_RecipeHolder.cs +++ b/Source/ProjectRimFactory/SAL3/Things/ITab_RecipeHolder.cs @@ -51,37 +51,32 @@ enum enum_RecipeStatus - private Dictionary Recipes { - - get + private void RefreshRecipeList() + { + Recipes = new Dictionary(); + foreach (RecipeDef r in parrentDB.Learnable_Recipes) { - - Dictionary lRecipes = new Dictionary(); - foreach (RecipeDef r in parrentDB.Learnable_Recipes) + if (parrentDB.Quered_Recipes.Contains(r)) { - if (parrentDB.Quered_Recipes.Contains(r)) - { - lRecipes[r] = enum_RecipeStatus.Quered; - }else if (parrentDB.Recipe_Learning == r) - { - lRecipes[r] = enum_RecipeStatus.InPorogress; - } - else - { - lRecipes[r] = enum_RecipeStatus.Learnable; - } + Recipes[r] = enum_RecipeStatus.Quered; } - foreach (RecipeDef r in parrentDB.Saved_Recipes) + else if (parrentDB.Recipe_Learning == r) { - lRecipes[r] = enum_RecipeStatus.Saved; + Recipes[r] = enum_RecipeStatus.InPorogress; + } + else + { + Recipes[r] = enum_RecipeStatus.Learnable; } - - return lRecipes; } - - + foreach (RecipeDef r in parrentDB.Saved_Recipes) + { + Recipes[r] = enum_RecipeStatus.Saved; + } } + private Dictionary Recipes; + @@ -100,7 +95,9 @@ public ITab_RecipeHolder() private bool ShouldDrawRow(RecipeDef recipe, ref float curY, float ViewRecthight, float scrollY) { - + 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; //The item is above the view (including a safty margin of one item) if ((curY + ROW_HIGHT - scrollY) < 0) @@ -113,9 +110,7 @@ private bool ShouldDrawRow(RecipeDef recipe, ref float curY, float ViewRecthight if ((curY - ROW_HIGHT - scrollY - ViewRecthight) < 0) { - 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; + return true; } @@ -131,6 +126,7 @@ private bool ShouldDrawRow(RecipeDef recipe, ref float curY, float ViewRecthight protected override void FillTab() { + RefreshRecipeList(); Listing_Standard list = new Listing_Standard(); Rect inRect = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f);