diff --git a/Models/PlayerProfile.cs b/Models/PlayerProfile.cs --- a/Models/PlayerProfile.cs +++ b/Models/PlayerProfile.cs @@ -617,6 +617,52 @@ namespace DesertPaintCodex.Models } } + public void ExportPaintMixRecipes(string file) + { + StreamWriter writer = new(file); + ExportPaintMixFormat(writer, Recipes); + } + + public void ExportPaintMixRibbons(string file) + { + StreamWriter writer = new StreamWriter(file); + ExportPaintMixFormat(writer, this.RibbonRecipes); + } + + public void ExportPaintMixRecipes(TextWriter writer) + { + ExportPaintMixFormat(writer, this.Recipes); + } + + public void ExportPaintMixRibbons(TextWriter writer) + { + ExportWikiFormat(writer, this.RibbonRecipes); + } + + public static void ExportPaintMixFormat(TextWriter writer, Dictionary 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) + { + colorLine += $" {ingredient.Name} {ingredient.Quantity}"; + } + colorLine += $" - #{color.Red:X2}{color.Green:X2}{color.Blue:X2}"; + writer.WriteLine(colorLine); + } + else + { + // no recipe + } + } + } + } + public Reaction? FindReaction(Reagent? reagent1, Reagent? reagent2) { if ((reagent1 == null) || (reagent2 == null)) return null; diff --git a/ViewModels/MainWindowViewModel.cs b/ViewModels/MainWindowViewModel.cs --- a/ViewModels/MainWindowViewModel.cs +++ b/ViewModels/MainWindowViewModel.cs @@ -166,6 +166,15 @@ namespace DesertPaintCodex.ViewModels } } + public static async void ExportPaintMixRecipes() + { + string? fileName = await GetSaveFileName("Export paint_mix recipes", NoFileFilters, "paint_recipes.txt"); + if (!string.IsNullOrEmpty(fileName)) + { + ProfileManager.CurrentProfile?.ExportPaintMixRecipes(fileName); + } + } + public static async void CopyPaintRecipes() { StringWriter writer = new(); diff --git a/Views/MainWindow.axaml b/Views/MainWindow.axaml --- a/Views/MainWindow.axaml +++ b/Views/MainWindow.axaml @@ -86,12 +86,12 @@ - + Exports recipes in Wiki table format. - + Exports recipes in Wiki table format. @@ -107,6 +107,11 @@ Copies recipes in Wiki table format. + + + Exports recipes in Wiki table format. + +