Changeset - 71732f305328
[Not reviewed]
default
8 7 0
Jason Maltzen (jmaltzen) - 9 years ago 2015-12-26 03:04:25
jason.maltzen@unsanctioned.net
Pre-allocate a bunch of map entries, given that we know there are a fixed set of colors. Use fixed arrays in places where maps/sets were excessive. Switch away from using Gtk.Application.Invoke, which leaks a bunch of memory.
15 files changed with 262 insertions and 556 deletions:
0 comments (0 inline, 0 general)
DesertPaintLab.csproj
Show inline comments
...
 
@@ -74,3 +74,5 @@
 
    <Compile Include="FileUtils.cs" />
 
    <Compile Include="PaintRecipe.cs" />
 
    <Compile Include="PaintRecipe.cs">
 
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
 
    </Compile>
 
    <Compile Include="ReactionRecorder.cs" />
...
 
@@ -97,2 +99,14 @@
 
  </ProjectExtensions>
 
  <ItemGroup>
 
    <None Include="data\colors.txt">
 
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
 
    </None>
 
    <None Include="data\ingredients.txt">
 
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
 
    </None>
 
    <None Include="data\template\dp_reactions.txt">
 
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
 
    </None>
 
    <None Include="data\template\ingredients.txt" />
 
  </ItemGroup>
 
</Project>
...
 
\ No newline at end of file
PaintRecipe.cs
Show inline comments
...
 
@@ -46,2 +46,13 @@ namespace DesertPaintLab
 
            }
 

	
 
            public RecipeIngredient(RecipeIngredient other)
 
            {
 
                this.name = other.name;
 
                this.quantity = other.quantity;
 
            }
 

	
 
            public override string ToString()
 
            {
 
                return String.Format("{0} {1}", name, quantity);
 
            }
 
        };
...
 
@@ -70,3 +81,20 @@ namespace DesertPaintLab
 
            {
 
                RecipeIngredient ingredient = new RecipeIngredient(copyIngredient.name, copyIngredient.quantity);
 
                RecipeIngredient ingredient = new RecipeIngredient(copyIngredient);
 
                this.recipe.Add(ingredient);
 
            }
 
        }
 

	
 
        public void CopyFrom(PaintRecipe other)
 
        {
 
            this.dirty = true;
 
            this.reactions = other.reactions;
 
            this.reagents.Clear();
 
            foreach (string reagentName in other.reagents)
 
            {
 
                this.reagents.Add(reagentName);
 
            }
 
            this.recipe.Clear();
 
            foreach (RecipeIngredient otherIngredient in other.recipe)
 
            {
 
                RecipeIngredient ingredient = new RecipeIngredient(otherIngredient);
 
                this.recipe.Add(ingredient);
PlayerProfile.cs
Show inline comments
...
 
@@ -61,2 +61,7 @@ namespace DesertPaintLab
 
            this.reagentFile = System.IO.Path.Combine(directory, "ingredients.txt");
 
            this.recipes = new SortedDictionary<string, PaintRecipe>();
 
            foreach (PaintColor color in Palette.Colors)
 
            {
 
                this.recipes.Add(color.Name, new PaintRecipe());
 
            }
 
		}
...
 
@@ -91,2 +96,17 @@ namespace DesertPaintLab
 
		
 
        public int RecipeCount
 
        {
 
            get {
 
                int count = 0;
 
                foreach (PaintRecipe recipe in this.recipes.Values)
 
                {
 
                    if (recipe.IsValid)
 
                    {
 
                        ++count;
 
                    }
 
                }
 
                return count;
 
            }
 
        }
 
		
 
		public void Initialize()
...
 
@@ -320,3 +340,6 @@ namespace DesertPaintLab
 
        {
 
            this.recipes = new SortedDictionary<string, PaintRecipe>();
 
            foreach (PaintRecipe recipe in this.recipes.Values)
 
            {
 
                recipe.Clear();
 
            }
 
            string recipeFile = System.IO.Path.Combine(directory, "dp_recipes.txt");
...
 
@@ -325,3 +348,4 @@ namespace DesertPaintLab
 
            bool inRecipe = false;
 
            PaintRecipe recipe = null;
 
            PaintRecipe testRecipe = new PaintRecipe();
 
            testRecipe.Reactions = reactions;
 
            string currentRecipeColor = null;
...
 
@@ -336,8 +360,7 @@ namespace DesertPaintLab
 
                        {
 
                            if (recipe != null && currentRecipeColor != null)
 
                            if (testRecipe != null && currentRecipeColor != null)
 
                            {
 
                                recipes.Add(currentRecipeColor, recipe);
 
                                recipes[currentRecipeColor].CopyFrom(testRecipe);
 
                            }
 
                            recipe = new PaintRecipe();
 
                            recipe.Reactions = reactions;
 
                            testRecipe.Clear();
 
                            currentRecipeColor = match.Groups["colorname"].Value;
...
 
@@ -352,3 +375,3 @@ namespace DesertPaintLab
 
                                uint quantity = uint.Parse(match.Groups["quantity"].Value);
 
                                recipe.AddReagent(ingredient, quantity);
 
                                testRecipe.AddReagent(ingredient, quantity);
 
                            }
...
 
@@ -358,3 +381,3 @@ namespace DesertPaintLab
 
                    {
 
                        recipes.Add(currentRecipeColor, recipe);
 
                        recipes[currentRecipeColor].CopyFrom(testRecipe);
 
                    }
...
 
@@ -405,3 +428,3 @@ namespace DesertPaintLab
 
                        {
 
                            colorLine += " " + ingredient.name + " " + ingredient.quantity.ToString();
 
                            colorLine += " " + ingredient.ToString();
 
                        }
...
 
@@ -432,3 +455,3 @@ namespace DesertPaintLab
 
            string colorName = Palette.FindNearest(recipe.ReactedColor);
 
            recipes[colorName] = recipe;
 
            recipes[colorName].CopyFrom(recipe);
 
        }
RecipeGenerator.cs
Show inline comments
...
 
@@ -62,4 +62,4 @@ namespace DesertPaintLab
 
            //int initialReagentCount;
 
            List<uint> reagents;
 
            public List<uint> Reagents
 
            uint[] reagents;
 
            public uint[] Reagents
 
            {
...
 
@@ -70,4 +70,13 @@ namespace DesertPaintLab
 
            }
 
            uint INVALID_REAGENT;
 
            int nextReagentPos;
 
            public int ReagentCount
 
            {
 
                get
 
                {
 
                    return nextReagentPos;
 
                }
 
            }
 

	
 
            HashSet<uint> reagentInUse = new HashSet<uint>();
 
            bool[] reagentInUse;
 
            List<Reagent> costSortedReagents;
...
 
@@ -115,12 +124,34 @@ namespace DesertPaintLab
 

	
 
            public SearchNode(List<Reagent> costSortedReagents, List<uint> reagents)
 
            public SearchNode(List<Reagent> costSortedReagents, uint[] reagents)
 
            {
 
                this.costSortedReagents = new List<Reagent>(costSortedReagents);
 
                this.reagents = new List<uint>(reagents);
 
                foreach (uint reagentIdx in reagents)
 
                this.reagents = new uint[costSortedReagents.Count];
 
                INVALID_REAGENT = (uint)costSortedReagents.Count;
 
                nextReagentPos = reagents.Length;
 
                for (int i = this.reagents.Length-1; i >= this.reagents.Length; --i)
 
                {
 
                    reagents[i] = INVALID_REAGENT;
 
                }
 
                for (int i = reagents.Length-1; i >= 0; --i)
 
                {
 
                    this.reagents[i] = reagents[i];
 
                    if (reagents[i] == INVALID_REAGENT)
 
                {
 
                    reagentInUse.Add(reagentIdx);
 
                        nextReagentPos = i;
 
                    }
 
                }
 
                reagentInUse = new bool[costSortedReagents.Count];
 
                for (uint reagentIdx = 0; reagentIdx < costSortedReagents.Count; ++reagentIdx)
 
                {
 
                    reagentInUse[reagentIdx] = false;
 
                }
 
                InitialCount = this.reagents.Count;
 
                MaxReagents = (uint)this.reagents.Count; // better set this later!
 
                foreach (uint reagentIdx in this.reagents)
 
                {
 
                    if (reagentIdx != INVALID_REAGENT)
 
                    {
 
                        reagentInUse[reagentIdx] = true;
 
                    }
 
                }
 
                InitialCount = nextReagentPos;
 
                MaxReagents = (uint)nextReagentPos; // better set this later!
 
                UsedQuantity = 0;
...
 
@@ -132,4 +163,15 @@ namespace DesertPaintLab
 
                this.costSortedReagents = new List<Reagent>(costSortedReagents);
 
                this.reagents = new List<uint>();
 
                this.reagents.Add(NextFreeReagent(startReagent));
 
                this.reagents = new uint[costSortedReagents.Count];
 
                INVALID_REAGENT = (uint)costSortedReagents.Count;
 
                nextReagentPos = 0;
 
                for (int i = 0; i < reagents.Length; ++i)
 
                {
 
                    this.reagents[i] = INVALID_REAGENT;
 
                }
 
                reagentInUse = new bool[costSortedReagents.Count];
 
                for (uint reagentIdx = 0; reagentIdx < costSortedReagents.Count; ++reagentIdx)
 
                {
 
                    reagentInUse[reagentIdx] = false;
 
                }
 
                this.reagents[nextReagentPos++] = NextFreeReagent(startReagent);
 
                InitialCount = 1; // don't iterate up beyond the start reagent
...
 
@@ -142,4 +184,15 @@ namespace DesertPaintLab
 
                this.costSortedReagents = costSortedReagents;
 
                this.reagents = new List<uint>();
 
                this.reagents.Add(NextFreeReagent(0));
 
                this.reagents = new uint[costSortedReagents.Count];
 
                INVALID_REAGENT = (uint)costSortedReagents.Count;
 
                nextReagentPos = 0;
 
                for (int i = 0; i < reagents.Length; ++i)
 
                {
 
                    this.reagents[i] = INVALID_REAGENT;
 
                }
 
                reagentInUse = new bool[costSortedReagents.Count];
 
                for (uint reagentIdx = 0; reagentIdx < costSortedReagents.Count; ++reagentIdx)
 
                {
 
                    reagentInUse[reagentIdx] = false;
 
                }
 
                this.reagents[nextReagentPos++] = NextFreeReagent(0);
 
                InitialCount = 0;
...
 
@@ -158,3 +211,3 @@ namespace DesertPaintLab
 
                {
 
                    return reagents[reagents.Count - 1];
 
                    return reagents[nextReagentPos - 1];
 
                }
...
 
@@ -164,3 +217,3 @@ namespace DesertPaintLab
 
            {
 
                uint reagentIdx = reagents[reagents.Count-1];
 
                uint reagentIdx = reagents[nextReagentPos-1];
 
                ReleaseReagent(reagentIdx);
...
 
@@ -170,3 +223,4 @@ namespace DesertPaintLab
 
                }
 
                reagents.RemoveAt(reagents.Count-1);
 
                reagents[nextReagentPos-1] = INVALID_REAGENT;
 
                --nextReagentPos;
 
            }
...
 
@@ -175,5 +229,5 @@ namespace DesertPaintLab
 
            {
 
                uint oldReagentIdx = reagents[reagents.Count-1];
 
                uint oldReagentIdx = reagents[nextReagentPos-1];
 
                ReleaseReagent(oldReagentIdx);
 
                reagents[reagents.Count-1] = reagentIdx;
 
                reagents[nextReagentPos-1] = reagentIdx;
 
                if (costSortedReagents[(int)oldReagentIdx].IsCatalyst)
...
 
@@ -193,3 +247,3 @@ namespace DesertPaintLab
 
                {
 
                    bool inUse = reagentInUse.Contains(idx);
 
                    bool inUse = reagentInUse[idx];
 
                    if (inUse == false)
...
 
@@ -197,3 +251,3 @@ namespace DesertPaintLab
 
                        //Console.WriteLine("Found free reagent idx {0}", idx);
 
                        reagentInUse.Add(idx);
 
                        reagentInUse[idx] = true;
 
                        return idx;
...
 
@@ -207,3 +261,3 @@ namespace DesertPaintLab
 
            {
 
                reagentInUse.Remove(reagentIdx);
 
                reagentInUse[reagentIdx] = false;
 
            }
...
 
@@ -212,3 +266,3 @@ namespace DesertPaintLab
 
            {
 
                bool ok = (reagents.Count < MaxReagents);
 
                bool ok = (nextReagentPos < MaxReagents);
 
                if (ok)
...
 
@@ -216,3 +270,3 @@ namespace DesertPaintLab
 
                    uint nextReagent = NextFreeReagent(0);
 
                    reagents.Add(nextReagent);
 
                    reagents[nextReagentPos++] = nextReagent;
 
                    if (costSortedReagents[(int)nextReagent].IsCatalyst)
...
 
@@ -235,5 +289,5 @@ namespace DesertPaintLab
 
                UsedQuantity = 0;
 
                uint remainingReagents = ((uint)reagents.Count - CatalystCount);
 
                uint remainingReagents = ((uint)nextReagentPos - CatalystCount);
 
                uint remainingWeight = CurrentTargetQuantity - CatalystCount;
 
                for (int i = 0; i < reagents.Count; ++i)
 
                for (int i = 0; i < nextReagentPos; ++i)
 
                {
...
 
@@ -268,4 +322,4 @@ namespace DesertPaintLab
 
                writer.WriteLine("MaxReagents: {0}", MaxReagents);
 
                writer.WriteLine("Reagents: {0}", reagents.Count);
 
                for (int i = 0; i < reagents.Count; ++i)
 
                writer.WriteLine("Reagents: {0}", nextReagentPos);
 
                for (int i = 0; i < nextReagentPos; ++i)
 
                {
...
 
@@ -273,3 +327,3 @@ namespace DesertPaintLab
 
                    uint weight = currentWeights[i];
 
                    writer.WriteLine("Reagent: {0},{1},{2}", idx, reagentInUse.Contains(idx) ? 1 : 0, weight);
 
                    writer.WriteLine("Reagent: {0},{1},{2}", idx, reagentInUse[idx] ? 1 : 0, weight);
 
                }
...
 
@@ -298,3 +352,2 @@ namespace DesertPaintLab
 
                Match match;
 
                int reagentIdx = 0;
 
                while ((line = reader.ReadLine()) != null)
...
 
@@ -312,6 +365,9 @@ namespace DesertPaintLab
 
                                {
 
                                    int reagentCount = int.Parse(match.Groups[2].Value);
 
                                    reagents = new List<uint>(reagentCount);
 
                                    reagentInUse.Clear();
 
                                    reagentIdx = 0;
 
                                    //int reagentCount = int.Parse(match.Groups[2].Value);
 
                                    for (int i = 0; i < reagents.Length; ++i)
 
                                    {
 
                                        reagents[i] = INVALID_REAGENT;
 
                                        reagentInUse[i] = false;
 
                                    }
 
                                    nextReagentPos = 0;
 
                                }
...
 
@@ -326,8 +382,9 @@ namespace DesertPaintLab
 
                                        uint weight = uint.Parse(reagentInfo.Groups["weight"].Value);
 
                                        reagents.Add(reagentId);
 
                                        currentWeights[reagentIdx] = weight;
 
                                        reagents[nextReagentPos] = reagentId;
 
                                        currentWeights[nextReagentPos] = weight;
 
                                        if (isInUse != 0)
 
                                        {
 
                                            reagentInUse.Add(reagentId);
 
                                            reagentInUse[reagentId] = true;
 
                                        }
 
                                        ++nextReagentPos;
 
                                    }
...
 
@@ -427,2 +484,7 @@ namespace DesertPaintLab
 
            this.reactions = reactions;
 
            foreach (PaintColor color in Palette.Colors)
 
            {
 
                recipes.Add(color.Name, new PaintRecipe());
 
                recipeCosts.Add(color.Name, uint.MaxValue);
 
            }
 
        }
...
 
@@ -461,3 +523,3 @@ namespace DesertPaintLab
 

	
 
        public void InitRecipes(SortedDictionary<string, PaintRecipe> recipes)
 
        public void InitRecipes(SortedDictionary<string, PaintRecipe> initialRecipes)
 
        {
...
 
@@ -467,6 +529,6 @@ namespace DesertPaintLab
 
            }
 
            foreach (PaintRecipe recipe in recipes.Values)
 
            foreach (PaintRecipe recipe in initialRecipes.Values)
 
            {
 
                PaintRecipe recipeCopy = new PaintRecipe(recipe);
 
                AddCheapestRecipe(recipeCopy);
 
                //PaintRecipe recipeCopy = new PaintRecipe(recipe);
 
                AddCheapestRecipe(recipe);
 
            }
...
 
@@ -510,2 +572,4 @@ namespace DesertPaintLab
 
            // 2) any previously-generated recipes
 
            PaintRecipe recipe = new PaintRecipe();
 
            recipe.Reactions = reactions;
 
            foreach (Reagent reagent in costSortedReagents)
...
 
@@ -514,4 +578,3 @@ namespace DesertPaintLab
 
                {
 
                    PaintRecipe recipe = new PaintRecipe();
 
                    recipe.Reactions = reactions;
 
                    recipe.Clear();
 
                    recipe.AddReagent(reagent.Name, 10);
...
 
@@ -764,5 +827,4 @@ namespace DesertPaintLab
 
        // returns the discarded recipe from the pair (or null if no original recipe to replace)
 
        private PaintRecipe AddCheapestRecipe(PaintRecipe recipe)
 
        private void AddCheapestRecipe(PaintRecipe recipe)
 
        {
 
            PaintRecipe discarded = recipe;
 
            if (recipe.IsValid)
...
 
@@ -784,5 +846,4 @@ namespace DesertPaintLab
 
                        {
 
                            discarded = recipes[colorName];
 
                            recipes[colorName].CopyFrom(recipe);
 
                            recipeCosts[colorName] = recipe.Cost;
 
                            recipes[colorName] = recipe;
 
                            if (NewRecipe != null)
...
 
@@ -796,5 +857,5 @@ namespace DesertPaintLab
 
                    {
 
                        discarded = null;
 
                        // This would be an error!
 
                        recipeCosts.Add(colorName, recipe.Cost);
 
                        recipes.Add(colorName, recipe);
 
                        recipes.Add(colorName, new PaintRecipe(recipe));
 
                        if (NewRecipe != null)
...
 
@@ -818,4 +879,2 @@ namespace DesertPaintLab
 
            //}
 
            
 
            return discarded;
 
        }
...
 
@@ -847,3 +906,3 @@ namespace DesertPaintLab
 
                {
 
                    while ((node.Reagents.Count > node.InitialCount) && (node.LastReagent == (totalReagents-1)))
 
                    while ((node.ReagentCount > node.InitialCount) && (node.LastReagent == (totalReagents-1)))
 
                    {
...
 
@@ -851,3 +910,3 @@ namespace DesertPaintLab
 
                    }
 
                    if (node.Reagents.Count == node.InitialCount)
 
                    if (node.ReagentCount == node.InitialCount)
 
                    {
...
 
@@ -857,3 +916,3 @@ namespace DesertPaintLab
 
                    uint nextReagent = node.NextFreeReagent(node.LastReagent);
 
                    while ((node.Reagents.Count > node.InitialCount) && (nextReagent >= totalReagents))
 
                    while ((node.ReagentCount > node.InitialCount) && (nextReagent >= totalReagents))
 
                    {
...
 
@@ -861,3 +920,3 @@ namespace DesertPaintLab
 
                        node.RemoveLastReagent();
 
                        if (node.Reagents.Count > node.InitialCount)
 
                        if (node.ReagentCount > node.InitialCount)
 
                        {
...
 
@@ -866,3 +925,3 @@ namespace DesertPaintLab
 
                    }
 
                    if (node.Reagents.Count == node.InitialCount)
 
                    if (node.ReagentCount == node.InitialCount)
 
                    {
...
 
@@ -899,3 +958,3 @@ namespace DesertPaintLab
 
            node.TestRecipe.Clear();
 
            for (int i = 0; i < node.Reagents.Count; ++i)
 
            for (int i = 0; i < node.ReagentCount; ++i)
 
            {
...
 
@@ -903,12 +962,3 @@ namespace DesertPaintLab
 
            }
 
            PaintRecipe replacement = AddCheapestRecipe(node.TestRecipe);
 
            if (replacement == null)
 
            {
 
                node.TestRecipe = new PaintRecipe();
 
                node.TestRecipe.Reactions = reactions;
 
            }
 
            else
 
            {
 
                node.TestRecipe = replacement;
 
            }
 
            AddCheapestRecipe(node.TestRecipe);
 
            
...
 
@@ -923,3 +973,3 @@ namespace DesertPaintLab
 

	
 
            uint depth = (uint)node.Reagents.Count;
 
            uint depth = (uint)node.ReagentCount;
 
            uint weightToConsume = 0;
...
 
@@ -1012,4 +1062,10 @@ namespace DesertPaintLab
 
        {
 
            recipes.Clear();
 
            recipeCosts.Clear();
 
            foreach (PaintRecipe recipe in recipes.Values)
 
            {
 
                recipe.Clear();
 
            }
 
            foreach (string key in recipeCosts.Keys)
 
            {
 
                recipeCosts[key] = uint.MaxValue;
 
            }
 
        }
RecipeGeneratorWindow.cs
Show inline comments
...
 
@@ -24,2 +24,3 @@ using System;
 
using System.Collections.Generic;
 
using System.Collections.Concurrent;
 

	
...
 
@@ -56,2 +57,8 @@ namespace DesertPaintLab
 

	
 
        Gtk.ThreadNotify notifyFinished;
 
        Gtk.ThreadNotify notifyProgress;
 
        Gtk.ThreadNotify notifyNewRecipe;
 

	
 
        ConcurrentQueue<PaintRecipe> pendingNewRecipes = new ConcurrentQueue<PaintRecipe>();
 

	
 
        public RecipeGeneratorWindow(PlayerProfile profile) : base(Gtk.WindowType.Toplevel)
...
 
@@ -86,5 +93,9 @@ namespace DesertPaintLab
 
            // init UI
 
            foreach (string key in profile.Recipes.Keys)
 
            foreach (KeyValuePair<string, PaintRecipe> pair in profile.Recipes)
 
            {
 
                if (pair.Value.IsValid)
 
            {
 
                colorStore.AppendValues(key);
 
                    string colorName = pair.Key;
 
                    colorStore.AppendValues(colorName);
 
                }
 
            }
...
 
@@ -113,5 +124,9 @@ namespace DesertPaintLab
 
            }
 
            countLabel.Text = String.Format("{0} / {1}", generator.Recipes.Count, Palette.Count);
 
            countLabel.Text = String.Format("{0} / {1}", profile.RecipeCount, Palette.Count);
 

	
 
            Destroyed += OnDestroyed;
 

	
 
            notifyFinished = new Gtk.ThreadNotify(new Gtk.ReadyEvent(HandleFinished));
 
            notifyProgress = new Gtk.ThreadNotify(new Gtk.ReadyEvent(HandleProgress));
 
            notifyNewRecipe = new Gtk.ThreadNotify(new Gtk.ReadyEvent(HandleNewRecipe));
 
        }
...
 
@@ -153,3 +168,3 @@ namespace DesertPaintLab
 

	
 
            countLabel.Text = String.Format("{0} / {1}", generator.Recipes.Count, Palette.Count);
 
            countLabel.Text = String.Format("{0} / {1}", profile.RecipeCount, Palette.Count);
 

	
...
 
@@ -214,5 +229,4 @@ namespace DesertPaintLab
 

	
 
        protected void OnFinished(object sender, EventArgs args)
 
        private void HandleFinished()
 
        {
 
            Gtk.Application.Invoke(delegate {
 
                generator.Wait();
...
 
@@ -249,11 +263,20 @@ namespace DesertPaintLab
 
                }
 
            });
 
        }
 

	
 
        protected void OnNewRecipe(object sender, NewRecipeEventArgs args)
 
        protected void OnFinished(object sender, EventArgs args)
 
        {
 
            PaintRecipe recipe = new PaintRecipe(args.Recipe); // copy it
 
            Gtk.Application.Invoke(delegate
 
            notifyFinished.WakeupMain();
 
            //Gtk.Application.Invoke(delegate {
 
            //    HandleFinished();
 
            //});
 
        }
 

	
 
        private void HandleNewRecipe()
 
            {
 
                progressBar.Pulse();
 
            
 
            PaintRecipe recipe = null;
 
            if (pendingNewRecipes.TryDequeue(out recipe))
 
            {
 
                string recipeColor = Palette.FindNearest(recipe.ReactedColor);
 
                // TODO: Add item to recipe list only if not already listed
...
 
@@ -266,3 +289,3 @@ namespace DesertPaintLab
 
                        string color = (string)colorStore.GetValue(iter, 0);
 
                        if (color.Equals(args.Color))
 
                        if (color.Equals(recipeColor))
 
                        {
...
 
@@ -278,4 +301,4 @@ namespace DesertPaintLab
 
                    //    string missingReactionLabel = isMissingReactions ? "X" : "";
 
                    colorStore.AppendValues(args.Color); // , missingReactionLabel);
 
                    countLabel.Text = String.Format("{0} / {1}", generator.Recipes.Count, Palette.Count);
 
                    colorStore.AppendValues(recipeColor); // , missingReactionLabel);
 
                    countLabel.Text = String.Format("{0} / {1}", profile.RecipeCount+1, Palette.Count);
 
                }
...
 
@@ -290,10 +313,19 @@ namespace DesertPaintLab
 
                }
 
            });
 
            }
 
        }
 

	
 
        protected void OnProgress(object sender, EventArgs args)
 
        protected void OnNewRecipe(object sender, NewRecipeEventArgs args)
 
        {
 
            Gtk.Application.Invoke(delegate
 
            PaintRecipe recipe = new PaintRecipe(args.Recipe); // copy it, so the worker thread can release
 
            lock(this) {
 
                pendingNewRecipes.Enqueue(recipe);
 
            }
 
            notifyNewRecipe.WakeupMain();
 
            //Gtk.Application.Invoke(delegate {
 
            //    HandleNewRecipe();
 
            //});
 
        }
 

	
 
        private void HandleProgress()
 
            {
 
                // TODO: based on time rather than count
 
                long progressTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
...
 
@@ -302,4 +334,4 @@ namespace DesertPaintLab
 
                {
 
                lastProgressUpdate = progressTime;
 
                    progressBar.Pulse();
 
                    lastProgressUpdate = progressTime;
 
                }
...
 
@@ -308,8 +340,5 @@ namespace DesertPaintLab
 
                {
 
                    // Update recipe count label as well
 
                lastStatusUpdate = progressTime;
 
                    statusLabel.Text = String.Format("Recipes searched: {0:N00}", generator.RecipeCount);
 
                    lastStatusUpdate = progressTime;
 
                }
 
                //progressBar.Fraction = (double)((generator.RecipeCount / 10000) % 100) / 100.0;
 

	
 
                delta = progressTime - lastCheckpoint;
...
 
@@ -317,7 +346,11 @@ namespace DesertPaintLab
 
                {
 
                lastCheckpoint = progressTime;
 
                    pauseForCheckpoint = true;
 
                    lastCheckpoint = progressTime;
 
                    generator.Stop();
 
                }
 
            });
 
        }
 

	
 
        protected void OnProgress(object sender, EventArgs args)
 
        {
 
            notifyProgress.WakeupMain();
 
        }
bin/Debug/colors.txt
Show inline comments
 
deleted file
bin/Debug/ingredients.txt
Show inline comments
 
deleted file
bin/Debug/template/dp_reactions.txt
Show inline comments
 
deleted file
bin/Debug/template/ingredients.txt
Show inline comments
 
deleted file
bin/Release/colors.txt
Show inline comments
 
deleted file
bin/Release/ingredients.txt
Show inline comments
 
deleted file
bin/Release/template/dp_reactions.txt
Show inline comments
 
deleted file
bin/Release/template/ingredients.txt
Show inline comments
 
deleted file
gtk-gui/gui.stetic
Show inline comments
...
 
@@ -8,3 +8,3 @@
 
    <widget-library name="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
 
    <widget-library name="../bin/Release/DesertPaintLab.exe" internal="true" />
 
    <widget-library name="../bin/Debug/DesertPaintLab.exe" internal="true" />
 
  </import>
...
 
@@ -1192,3 +1192,3 @@ You can either import an existing Practi
 
            <property name="MemberName" />
 
            <node name="menubar1" type="Menubar">
 
            <node name="__gtksharp_64_Stetic_Editor_ActionMenuBar" type="Menubar">
 
              <node type="Menu" action="ExportAction">
mac/build-mac-bundle.sh
Show inline comments
...
 
@@ -17,5 +17,3 @@ fi
 
/bin/mkdir -p bin/DesertPaintLab.app/Contents/Resources
 
/bin/cp ../bin/Release/colors.txt bin/DesertPaintLab.app/Contents/Resources/
 
/bin/cp ../bin/Release/ingredients.txt bin/DesertPaintLab.app/Contents/Resources/
 
/bin/cp -r ../bin/Release/template bin/DesertPaintLab.app/Contents/Resources/template
 
/bin/cp -r ../data bin/DesertPaintLab.app/Contents/Resources/data
 

	
0 comments (0 inline, 0 general)