Changeset - 62d349a8db2f
[Not reviewed]
Jason Maltzen - 3 years ago 2021-08-27 21:58:31
jason@hiddenachievement.com
Fix the PaintMix export format - use the PracticalPaint internal names for ingredients, and remove excess whitespace. Also, don't export a recipe for colors that don't have a recipe.
1 file changed with 10 insertions and 6 deletions:
0 comments (0 inline, 0 general)
Models/PlayerProfile.cs
Show inline comments
...
 
@@ -634,43 +634,47 @@ namespace DesertPaintCodex.Models
 
            ExportPaintMixFormat(writer, this.Recipes);
 
        }
 

	
 
        public void ExportPaintMixRibbons(TextWriter writer)
 
        {
 
            ExportWikiFormat(writer, this.RibbonRecipes);
 
        }
 

	
 
        public static void ExportPaintMixFormat(TextWriter writer, Dictionary<string, PaintRecipe> recipeDict)
 
        {
 
            using (writer)
 
            {
 
                foreach (PaintColor color in PaletteService.Colors)
 
                {
 
                    if (recipeDict.TryGetValue(color.Name, out PaintRecipe? recipe))
 
                    {
 
                        string colorLine = $"{color.Name} : ";
 
                        foreach (PaintRecipe.ReagentQuantity ingredient in recipe.Reagents)
 
                        if (recipe.Reagents.Count > 0)
 
                        {
 
                            colorLine += $" {ingredient.Name} {ingredient.Quantity}";
 
                            string colorLine = $"{color.Name} :";
 
                            foreach (PaintRecipe.ReagentQuantity ingredient in recipe.Reagents)
 
                            {
 
                                Reagent reagent = ReagentService.GetReagent(ingredient.Name);
 
                                colorLine += $" {reagent.PracticalPaintName} {ingredient.Quantity}";
 
                            }
 
                            colorLine += $" - #{color.Red:X2}{color.Green:X2}{color.Blue:X2}";
 
                            writer.WriteLine(colorLine);
 
                        }
 
                        colorLine += $"  - #{color.Red:X2}{color.Green:X2}{color.Blue:X2}";
 
                        writer.WriteLine(colorLine);
 
                    }
 
                    else
 
                    {
 
                        // no recipe
 
                        // no recipe - skip
 
                    }
 
                }
 
            }
 
        }
 

	
 
        public Reaction? FindReaction(Reagent? reagent1, Reagent? reagent2)
 
        {
 
            if ((reagent1 == null) || (reagent2 == null)) return null;
 
            return Reactions.Find(reagent1, reagent2);
 
        }
 

	
 
        public void SetReaction(Reagent reagent1, Reagent reagent2, Reaction reaction)
 
        {
 
            Reactions.Set(reagent1, reagent2, reaction);
 
        }
 

	
0 comments (0 inline, 0 general)