Changeset - e53fa6e66029
[Not reviewed]
T9_V7 default
0 2 0
Jason Maltzen - 4 years ago 2019-11-08 22:36:00
jason@hiddenachievement.com
Add a button for marking a reaction as 'no reaction'
2 files changed with 62 insertions and 9 deletions:
0 comments (0 inline, 0 general)
UI/CaptureView.cs
Show inline comments
...
 
@@ -77,12 +77,13 @@ namespace DesertPaintLab
 
        }
 

	
 
        public void DisableRecord()
 
        {
 
            recordEnabled = false;
 
            recordButton.Sensitive = false;
 
            recordNoReactionButton.Sensitive = false;
 
        }
 

	
 
        public void EnableRecord()
 
        {
 
            recordEnabled = true;
 
            if (isCaptured)
...
 
@@ -151,56 +152,68 @@ namespace DesertPaintLab
 
            reagents[2] = null;
 
            
 
            bool reactionKnown = true;
 
            
 
            isCaptured = false;
 
            recordButton.Sensitive = false;
 
            recordNoReactionButton.Sensitive = false;
 
            clearReactionButton.Sensitive = false;
 
            clearReactionButton.Visible = false;
 
            recordNoReactionButton.Sensitive = false;
 
            recordNoReactionButton.Visible = false;
 
    
 
            recipe.Clear();
 
            
 
            if ((reagentName = GetSelectedReagentName(1)) == null)
 
            {
 
                // Nothing selected as reagent 1
 
                ingredient2ComboBox.Sensitive = false;
 
                ingredient3ComboBox.Sensitive = false;
 
                unmodifiedSwatch.Clear();
 
                reactionSwatch.Clear();
 
                captureButton.Sensitive = false;
 
                recordNoReactionButton.Sensitive = false;
 
                recordNoReactionButton.Visible = false;
 
                return;
 
            }
 
            recipe.AddReagent(reagentName);
 
            reagents[0] = ReagentManager.GetReagent(reagentName);
 
            ingredient2ComboBox.Sensitive = true;
 
            if ((reagentName = GetSelectedReagentName(2)) == null)
 
            {
 
                ingredient3ComboBox.Sensitive = false;
 
                recordButton.Sensitive = false;
 
                recordNoReactionButton.Sensitive = false;
 
                recordNoReactionButton.Visible = false;
 
                reactionKnown = false;
 
                reactionSwatch.Clear();
 
                return;
 
            }
 

	
 
            recipe.AddReagent(reagentName);
 
            reagents[1] = ReagentManager.GetReagent(reagentName);
 
            ingredient3ComboBox.Sensitive = true;
 
            captureButton.Sensitive = true;
 
            
 
            recordNoReactionButton.Sensitive = true;
 

	
 
            reaction1 = profile.FindReaction(reagents[0], reagents[1]);
 
            
 
            // TODO: really should handle reagent0==reagent1 better
 
            if ((reaction1 != null) || (reagents[0] == reagents[1]))
 
            {
 
                clearReactionButton.Sensitive = recordEnabled;
 
                clearReactionButton.Visible = true;
 
                ingredient3ComboBox.Sensitive = true;
 
                recordNoReactionButton.Sensitive = false;
 
                recordNoReactionButton.Visible = false;
 
                if ((reagentName = GetSelectedReagentName(3)) != null)
 
                {
 
                    clearReactionButton.Sensitive = false;
 
                    clearReactionButton.Visible = false;
 
                    recordNoReactionButton.Sensitive = false;
 
                    recordNoReactionButton.Visible = false;
 
                    recipe.AddReagent(reagentName);
 
                    reagents[2] = ReagentManager.GetReagent(reagentName);
 
            
 
                    if (!reactionKnown)
 
                    {
 
                        Gtk.MessageDialog md = new Gtk.MessageDialog((Gtk.Window)Toplevel, 
...
 
@@ -245,14 +258,16 @@ namespace DesertPaintLab
 
                }
 
            }
 
            else
 
            {
 
                reactionKnown = false;
 
                ingredient3ComboBox.Sensitive = false;
 
                recordNoReactionButton.Sensitive = recordEnabled;
 
                recordNoReactionButton.Visible = true;
 
            }
 
        
 

 
            expectedColor.Set(recipe.BaseColor);
 
            unmodifiedSwatch.Color = expectedColor;
 
            //SetExpectedColor(recipeColor.Red, recipeColor.Green, recipeColor.Blue);
 
            
 
            if (reactionKnown)
 
            {
...
 
@@ -269,15 +284,17 @@ namespace DesertPaintLab
 
        {
 
            captureButton.Sensitive = false;
 
            ingredient1ComboBox.Sensitive = false;
 
            ingredient2ComboBox.Sensitive = false;
 
            ingredient3ComboBox.Sensitive = false;
 
            clearReactionButton.Sensitive = false;
 
            recordNoReactionButton.Sensitive = false;
 

	
 
            progressBar.Show();
 
            recordButton.Hide();
 
            recordNoReactionButton.Hide();
 

	
 
            bool enableDebugMenu;
 
            AppSettings.Get("EnableDebugMenu", out enableDebugMenu, false);
 

	
 
            StreamWriter log = null;
 
            if (enableDebugMenu)
...
 
@@ -425,16 +442,18 @@ namespace DesertPaintLab
 
                    warning);
 

	
 
                    md.Run();
 
                    md.Destroy();
 
                    // reaction clipped - don't let them record
 
                    recordButton.Sensitive = false;
 
                    recordNoReactionButton.Sensitive = false;
 
                }
 
                else
 
                {
 
                    recordButton.Sensitive = recordEnabled;
 
                    recordNoReactionButton.Sensitive = false;
 
                }
 
            }
 
            else
 
            {
 
                Gtk.MessageDialog md = new Gtk.MessageDialog((Gtk.Window)Toplevel,
 
                    Gtk.DialogFlags.DestroyWithParent,
...
 
@@ -555,13 +574,26 @@ namespace DesertPaintLab
 
        {
 
            if (ReactionRecorder.Instance.RecordReaction(profile, expectedColor, reactedColor, reagents))
 
            {
 
                recordButton.Sensitive = false;
 
            }
 
        }
 
        
 

	
 
        protected virtual void OnRecordNoReaction(object sender, System.EventArgs e)
 
        {
 
            if (ReactionRecorder.Instance.RecordReaction(profile, expectedColor, expectedColor, reagents))
 
            {
 
                recordNoReactionButton.Sensitive = false;
 
                recordNoReactionButton.Visible = false;
 
                clearReactionButton.Sensitive = true;
 
                clearReactionButton.Visible = true;
 
                this.reactionSwatch.Color = expectedColor;
 
                this.reactedColor.Set(expectedColor);
 
            }
 
        }
 

	
 
        protected virtual void OnChangedIngredient1(object sender, System.EventArgs e)
 
        {
 
            UpdateIngredients();
 
        }
 
        
 
        protected virtual void OnChangedIngredient2(object sender, System.EventArgs e)
...
 
@@ -597,12 +629,18 @@ namespace DesertPaintLab
 
        
 
                    Gtk.ResponseType response = (Gtk.ResponseType)md.Run();
 
                    if (response == Gtk.ResponseType.Ok)
 
                    {
 
                        // really delete it
 
                        profile.ClearReaction(reagent1, reagent2);
 
                        reactionSwatch.Clear();
 
                        reactedColor.Clear();
 
                        clearReactionButton.Sensitive = false;
 
                        clearReactionButton.Visible = false;
 
                        recordNoReactionButton.Sensitive = true;
 
                        recordNoReactionButton.Visible = true;
 
                    }
 
                    md.Destroy();
 
                }
 
            }
 
        }
 
    }
gtk-gui/DesertPaintLab.CaptureView.cs
Show inline comments
...
 
@@ -54,12 +54,14 @@ namespace DesertPaintLab
 
		
 
		private global::Gtk.VBox vbox4;
 
		
 
		private global::DesertPaintLab.PaintSwatch reactionSwatch;
 
		
 
		private global::Gtk.Button recordButton;
 

	
 
        private global::Gtk.Button recordNoReactionButton;
 
		
 
		private global::Gtk.Label reactionLabel;
 

	
 
        private global::Gtk.ProgressBar progressBar;
 

	
 
        protected virtual void Build ()
...
 
@@ -154,27 +156,39 @@ namespace DesertPaintLab
 
			w8.Position = 1;
 
			this.vbox2.Add (this.hbox4);
 
			global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox4]));
 
			w9.Position = 2;
 
			w9.Expand = false;
 
			w9.Fill = false;
 
			// Container child vbox2.Gtk.Box+BoxChild
 
			this.clearReactionButton = new global::Gtk.Button ();
 
            // Container child vbox2.Gtk.Box+BoxChild
 
            this.clearReactionButton = new global::Gtk.Button ();
 
			this.clearReactionButton.Sensitive = false;
 
			this.clearReactionButton.CanFocus = true;
 
			this.clearReactionButton.Name = "clearReactionButton";
 
			this.clearReactionButton.UseUnderline = true;
 
			this.clearReactionButton.Label = "Clear Reaction";
 
			this.vbox2.Add (this.clearReactionButton);
 
			global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.clearReactionButton]));
 
			w10.PackType = ((global::Gtk.PackType)(1));
 
			w10.Position = 3;
 
			w10.Expand = false;
 
			w10.Fill = false;
 
			w10.Padding = ((uint)(6));
 
			this.GtkAlignment.Add (this.vbox2);
 
            this.recordNoReactionButton = new global::Gtk.Button();
 
            this.recordNoReactionButton.CanFocus = true;
 
            this.recordNoReactionButton.Name = "recordNoReactionButton";
 
            this.recordNoReactionButton.UseUnderline = true;
 
            this.recordNoReactionButton.Label = "No Reaction";
 
            this.vbox2.Add(this.recordNoReactionButton);
 
            global::Gtk.Box.BoxChild w21 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.recordNoReactionButton]));
 
            w21.PackType = ((global::Gtk.PackType)(1));
 
            w21.Position = 4;
 
            w21.Expand = false;
 
            w21.Fill = false;
 
            w21.Padding = ((uint)(6));
 
            this.GtkAlignment.Add (this.vbox2);
 
			this.selectIngredientsFrame.Add (this.GtkAlignment);
 
			this.selectIngredientsLabel = new global::Gtk.Label ();
 
			this.selectIngredientsLabel.Name = "selectIngredientsLabel";
 
			this.selectIngredientsLabel.LabelProp = "<b>Select Ingredients</b>";
 
			this.selectIngredientsLabel.UseMarkup = true;
 
			this.selectIngredientsFrame.LabelWidget = this.selectIngredientsLabel;
...
 
@@ -285,13 +299,13 @@ namespace DesertPaintLab
 
			this.recordButton.Label = "Record";
 
			this.vbox4.Add (this.recordButton);
 
			global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(this.vbox4 [this.recordButton]));
 
			w20.Position = 2;
 
			w20.Expand = false;
 
			w20.Fill = false;
 
			this.GtkAlignment2.Add (this.vbox4);
 
            this.GtkAlignment2.Add (this.vbox4);
 
			this.reactedColorFrame.Add (this.GtkAlignment2);
 
			this.reactionLabel = new global::Gtk.Label ();
 
			this.reactionLabel.Name = "reactionLabel";
 
			this.reactionLabel.LabelProp = "<b>Reacted</b>";
 
			this.reactionLabel.UseMarkup = true;
 
			this.reactionLabel.Justify = ((global::Gtk.Justification)(2));
...
 
@@ -312,9 +326,10 @@ namespace DesertPaintLab
 
			this.ingredient2ComboBox.Changed += new global::System.EventHandler (this.OnChangedIngredient2);
 
			this.ingredient3ComboBox.Changed += new global::System.EventHandler (this.OnChangedIngredient3);
 
			this.clearReactionButton.Clicked += new global::System.EventHandler (this.OnClearReaction);
 
			this.captureButton.Clicked += new global::System.EventHandler (this.OnCapture);
 
            this.captureFromFileButton.Clicked += new global::System.EventHandler(this.OnCaptureFromFile);
 
            this.recordButton.Clicked += new global::System.EventHandler (this.OnRecord);
 
		}
 
	}
 
            this.recordNoReactionButton.Clicked += new global::System.EventHandler(this.OnRecordNoReaction);
 
        }
 
    }
 
}
0 comments (0 inline, 0 general)