Changeset - 867b2b613117
[Not reviewed]
default
0 3 0
Jason Maltzen - 3 years ago 2021-08-16 07:53:33
jason@hiddenachievement.com
Add an export to paintmix option
3 files changed with 62 insertions and 2 deletions:
0 comments (0 inline, 0 general)
Models/PlayerProfile.cs
Show inline comments
...
 
@@ -614,12 +614,58 @@ namespace DesertPaintCodex.Models
 
                    writer.WriteLine(colorLine);
 
                }
 
                writer.WriteLine("|}");
 
            }
 
        }
 

	
 
        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<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)
 
                        {
 
                            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;
 
            return Reactions.Find(reagent1, reagent2);
 
        }
 

	
ViewModels/MainWindowViewModel.cs
Show inline comments
...
 
@@ -163,12 +163,21 @@ namespace DesertPaintCodex.ViewModels
 
            if (!string.IsNullOrEmpty(fileName))
 
            {
 
                ProfileManager.CurrentProfile?.ExportWikiRibbons(fileName);
 
            }
 
        }
 

	
 
        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();
 
            ProfileManager.CurrentProfile?.ExportWikiRecipes(writer);
 
            IClipboard clipboard = Application.Current.Clipboard;
 
            await writer.FlushAsync();
Views/MainWindow.axaml
Show inline comments
...
 
@@ -83,18 +83,18 @@
 
                                Will generate a Practical Paint reactions file from the current profile.
 
                            </ToolTip.Tip>
 
                        </MenuItem>
 
                    </MenuItem>
 
                    <Separator/>
 
                    <MenuItem Header="Recipes">
 
                        <MenuItem Header="Export Paint Recipes..." Command="{Binding ExportPaintRecipes}">
 
                        <MenuItem Header="Export Paint Recipes (Wiki format)..." Command="{Binding ExportPaintRecipes}">
 
                            <ToolTip.Tip>
 
                                Exports recipes in Wiki table format.
 
                            </ToolTip.Tip>
 
                        </MenuItem>
 
                        <MenuItem Header="Export Ribbon Recipes..." Command="{Binding ExportRibbonRecipes}">
 
                        <MenuItem Header="Export Ribbon Recipes (Wiki format)..." Command="{Binding ExportRibbonRecipes}">
 
                            <ToolTip.Tip>
 
                                Exports recipes in Wiki table format.
 
                            </ToolTip.Tip>
 
                        </MenuItem>
 
                        <Separator/>
 
                        <MenuItem Header="Copy Paint Recipes to Clipboard" Command="{Binding CopyPaintRecipes}">
...
 
@@ -104,12 +104,17 @@
 
                        </MenuItem>
 
                        <MenuItem Header="Copy Ribbon Recipes to Clipboard" Command="{Binding CopyRibbonRecipes}">
 
                            <ToolTip.Tip>
 
                                Copies recipes in Wiki table format.
 
                            </ToolTip.Tip>
 
                        </MenuItem>
 
                      <MenuItem Header="Export Paint Recipes (paint_mix format)..." Command="{Binding ExportPaintMixRecipes}">
 
                        <ToolTip.Tip>
 
                          Exports recipes in Wiki table format.
 
                        </ToolTip.Tip>
 
                      </MenuItem>
 
                    </MenuItem>
 

	
 
                    <Separator/>
 

	
 
                    <MenuItem Header="Screen Settings..." Command="{Binding ShowScreenSettings}"></MenuItem>
 
                    <Separator/>
0 comments (0 inline, 0 general)