Changeset - 5e28ba3945f7
[Not reviewed]
default
0 1 0
Jason Maltzen - 3 years ago 2021-09-10 00:03:21
jason@hiddenachievement.com
Recipe count is now a ulong instead of an int so it can show values > 2.47 billion. Also, don't allow clearing the recipe list while the recipe generator is running.
1 file changed with 12 insertions and 6 deletions:
0 comments (0 inline, 0 general)
ViewModels/RecipeGeneratorViewModel.cs
Show inline comments
...
 
@@ -91,5 +91,5 @@ namespace DesertPaintCodex.ViewModels
 

	
 
        private readonly ConcurrentQueue<PaintRecipe> _pendingNewRecipes = new();
 
        private volatile int _newRecipeCount;
 
        private ulong _newRecipeCount;
 
        private volatile bool _updatesAvailable;
 
        private readonly DispatcherTimer _updateTimer;
...
 
@@ -156,4 +156,6 @@ namespace DesertPaintCodex.ViewModels
 
            }
 

	
 
            CanClear = false;
 

	
 
            _generator.BeginRecipeGeneration(
 
                _minConcentration, 
...
 
@@ -202,4 +204,5 @@ namespace DesertPaintCodex.ViewModels
 
            }
 

	
 
            CanClear = false;
 
            _generator.ResumeRecipeGeneration();
 

	
...
 
@@ -300,5 +303,5 @@ namespace DesertPaintCodex.ViewModels
 
        private void OnProgress(object? sender, EventArgs args)
 
        {
 
            _newRecipeCount = (int)_generator.RecipeCount;
 
            _newRecipeCount = _generator.RecipeCount;
 
            _updatesAvailable = true;
 
        }
...
 
@@ -314,4 +317,5 @@ namespace DesertPaintCodex.ViewModels
 
        private void OnGeneratorStopped(object? sender, EventArgs args)
 
        {
 
            Debug.WriteLine($"Generator stopped. Saving = {_saving}");
 
            if (_saving)
 
            {
...
 
@@ -347,5 +351,6 @@ namespace DesertPaintCodex.ViewModels
 

	
 
            // Update test count.
 
            PermutationCount = $"{_newRecipeCount:n0}";
 
            ulong newRecipeCount = _newRecipeCount;
 
            PermutationCount = $"{newRecipeCount:n0}";
 
            
 
            // Pull in new recipes.
...
 
@@ -388,10 +393,11 @@ namespace DesertPaintCodex.ViewModels
 
            if (_unsavedRecipes)
 
            {
 
                Debug.WriteLine("Saving generator state.");
 
                _saving = true;
 
                _generator.Stop();
 

	
 
                _profile.SaveRecipes();
 
                _unsavedRecipes = false;
 
            }
 

	
 
            _saving = true;
 
            _generator.Stop();
 
        }
 
        
0 comments (0 inline, 0 general)