[gbrainy] Move DrawAnswer to Answer class



commit 8c6d9d37cdab3fd805caa36ee63e6dd1cd4826e0
Author: Jordi Mas <jmas softcatala org>
Date:   Wed Mar 2 21:23:05 2011 +0100

    Move DrawAnswer to Answer class

 src/Clients/Classical/gbrainy.cs                 |    4 ++--
 src/Core/Main/Game.cs                            |    6 ------
 src/Core/Main/GameAnswer.cs                      |    2 +-
 src/Core/Main/Memory.cs                          |    2 +-
 src/Games/Calculation/CalculationArithmetical.cs |    2 +-
 src/Games/Calculation/CalculationOperator.cs     |    4 ++--
 src/Games/Logic/PuzzleBuildTriangle.cs           |    2 +-
 src/Games/Logic/PuzzleCirclesSquare.cs           |    2 +-
 src/Games/Logic/PuzzleClocks.cs                  |    2 +-
 src/Games/Logic/PuzzleDivideCircle.cs            |    2 +-
 src/Games/Logic/PuzzleFigures.cs                 |    4 ++--
 src/Games/Logic/PuzzleFourSided.cs               |    2 +-
 src/Games/Logic/PuzzleSquareSheets.cs            |    2 +-
 src/Games/Logic/PuzzleTriangles.cs               |    2 +-
 src/Games/Memory/MemoryFigures.cs                |    2 +-
 src/Games/Memory/MemoryFiguresAndText.cs         |    2 +-
 src/Games/Memory/MemoryIndications.cs            |    2 +-
 17 files changed, 19 insertions(+), 25 deletions(-)
---
diff --git a/src/Clients/Classical/gbrainy.cs b/src/Clients/Classical/gbrainy.cs
index 665ec25..781de8f 100755
--- a/src/Clients/Classical/gbrainy.cs
+++ b/src/Clients/Classical/gbrainy.cs
@@ -489,7 +489,7 @@ namespace gbrainy.Clients.Classical
 			UpdateQuestion (session.CurrentGame.Question);
 			answer_entry.Text = string.Empty;
 			UpdateStatusBar ();
-			session.CurrentGame.DrawAnswer = false;
+			session.CurrentGame.Answer.Draw = false;
 			drawing_area.QueueDraw ();
 		}
 
@@ -534,7 +534,7 @@ namespace gbrainy.Clients.Classical
 				correct == true ? GameDrawingArea.SolutionType.CorrectAnswer :
 			        GameDrawingArea.SolutionType.InvalidAnswer);
 
-			session.CurrentGame.DrawAnswer = true;
+			session.CurrentGame.Answer.Draw = true;
 			ActiveInputControls (true);
 			next_button.GrabFocus ();
 			drawing_area.QueueDraw ();
diff --git a/src/Core/Main/Game.cs b/src/Core/Main/Game.cs
index b7cfb26..4b9b624 100644
--- a/src/Core/Main/Game.cs
+++ b/src/Core/Main/Game.cs
@@ -31,7 +31,6 @@ namespace gbrainy.Core.Main
 {
 	abstract public class Game : IDrawable, IDrawRequest, IMouseEvent
 	{
-		private bool draw_answer;
 		private Cairo.Color default_color;
 		protected Random random;
 		private TimeSpan game_time;
@@ -173,11 +172,6 @@ namespace gbrainy.Core.Main
 			get { return true;}
 		}
 
-		public bool DrawAnswer {
-			get { return draw_answer; }
-			set { draw_answer = value; }
-		}
-
 		// An initialized game cannot be playable (for example, missing external files)
 		public virtual bool IsPlayable {
 			get { return true;}
diff --git a/src/Core/Main/GameAnswer.cs b/src/Core/Main/GameAnswer.cs
index 1fd9717..bb52a7c 100644
--- a/src/Core/Main/GameAnswer.cs
+++ b/src/Core/Main/GameAnswer.cs
@@ -45,8 +45,8 @@ namespace gbrainy.Core.Main
 		}
 
 		public string Correct { get; set; }
-
 		public string CheckExpression { get; set; }
+		public bool Draw { get; set; }
 
 		public GameAnswerCheckAttributes CheckAttributes { get; set; }
 
diff --git a/src/Core/Main/Memory.cs b/src/Core/Main/Memory.cs
index 29db301..8e1c521 100644
--- a/src/Core/Main/Memory.cs
+++ b/src/Core/Main/Memory.cs
@@ -176,7 +176,7 @@ namespace gbrainy.Core.Main
 		
 			alpha = 1;
 			gr.Color = new Color (DefaultDrawingColor.R, DefaultDrawingColor.G, DefaultDrawingColor.B, alpha);
-			if (request_answer && DrawAnswer == false) {
+			if (request_answer && Answer.Draw == false) {
 				DrawPossibleAnswers (gr, area_width, area_height, rtl);
 			} else {
 				DrawObjectToMemorize (gr, area_width, area_height, rtl);
diff --git a/src/Games/Calculation/CalculationArithmetical.cs b/src/Games/Calculation/CalculationArithmetical.cs
index 056da69..cd57bf8 100644
--- a/src/Games/Calculation/CalculationArithmetical.cs
+++ b/src/Games/Calculation/CalculationArithmetical.cs
@@ -136,7 +136,7 @@ namespace gbrainy.Games.Calculation
 			gr.LineTo (DrawAreaX + 0.5, operand_y);
 			gr.Stroke ();
 
-			if (DrawAnswer) {
+			if (Answer.Draw) {
 				gr.DrawTextAlignedRight (aligned_pos, operand_y + 0.03, Answer.Correct);
 			}
 		}
diff --git a/src/Games/Calculation/CalculationOperator.cs b/src/Games/Calculation/CalculationOperator.cs
index 91b436a..c3a0626 100644
--- a/src/Games/Calculation/CalculationOperator.cs
+++ b/src/Games/Calculation/CalculationOperator.cs
@@ -131,10 +131,10 @@ namespace gbrainy.Games.Calculation
 			gr.DrawTextAlignedRight (aligned_pos, DrawAreaY + 0.55, total.ToString ());
 
 			gr.MoveTo (DrawAreaX + 0.2, DrawAreaY + 0.25);
-			gr.ShowPangoText ((DrawAnswer == true) ? oper1.ToString () : "?");
+			gr.ShowPangoText ((Answer.Draw == true) ? oper1.ToString () : "?");
 
 			gr.MoveTo (DrawAreaX + 0.2, DrawAreaY + 0.35);
-			gr.ShowPangoText ((DrawAnswer == true) ?  oper2.ToString () : "?");
+			gr.ShowPangoText ((Answer.Draw == true) ?  oper2.ToString () : "?");
 
 		}
 	}
diff --git a/src/Games/Logic/PuzzleBuildTriangle.cs b/src/Games/Logic/PuzzleBuildTriangle.cs
index 79ef6b2..c6201bc 100644
--- a/src/Games/Logic/PuzzleBuildTriangle.cs
+++ b/src/Games/Logic/PuzzleBuildTriangle.cs
@@ -169,7 +169,7 @@ namespace gbrainy.Games.Logic
 					x+= space_figures;
 			}
 
-			if (DrawAnswer == false)
+			if (Answer.Draw == false)
 				return;
 
 			gr.MoveTo (DrawAreaX, y + 0.28);
diff --git a/src/Games/Logic/PuzzleCirclesSquare.cs b/src/Games/Logic/PuzzleCirclesSquare.cs
index 22409c7..7943a37 100644
--- a/src/Games/Logic/PuzzleCirclesSquare.cs
+++ b/src/Games/Logic/PuzzleCirclesSquare.cs
@@ -136,7 +136,7 @@ namespace gbrainy.Games.Logic
 			gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("1 unit"), false, -1, 270 * Math.PI/180);
 			gr.Stroke ();
 
-			if (DrawAnswer == false)
+			if (Answer.Draw == false)
 				return;
 
 			double x;
diff --git a/src/Games/Logic/PuzzleClocks.cs b/src/Games/Logic/PuzzleClocks.cs
index 29eaa35..1639b1a 100644
--- a/src/Games/Logic/PuzzleClocks.cs
+++ b/src/Games/Logic/PuzzleClocks.cs
@@ -136,7 +136,7 @@ namespace gbrainy.Games.Logic
 
 			drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e)
 			{
-				DrawClock (e.Context, 0.2, 0.16, handles[6], handles[7], DrawAnswer == true);
+				DrawClock (e.Context, 0.2, 0.16, handles[6], handles[7], Answer.Draw == true);
 				e.Context.MoveTo (0.03, 0.29);
 				e.Context.DrawTextCentered (drawable_area.Width / 2, 0.36, Answer.GetMultiOptionFigureName (3));
 				e.Context.Stroke ();
diff --git a/src/Games/Logic/PuzzleDivideCircle.cs b/src/Games/Logic/PuzzleDivideCircle.cs
index c7f57b4..aca1dc7 100644
--- a/src/Games/Logic/PuzzleDivideCircle.cs
+++ b/src/Games/Logic/PuzzleDivideCircle.cs
@@ -171,7 +171,7 @@ namespace gbrainy.Games.Logic
 			pos_x += 0.4;
 			gr.Arc (pos_x + figure_size, pos_y + figure_size, figure_size, 0, 2 * Math.PI);
 			gr.Stroke ();		
-			DrawAndConnectPoints (gr, pos_x, pos_y, circles, DrawAnswer);
+			DrawAndConnectPoints (gr, pos_x, pos_y, circles, Answer.Draw);
 		}
 		
 		string HasNRegionString (int regions)
diff --git a/src/Games/Logic/PuzzleFigures.cs b/src/Games/Logic/PuzzleFigures.cs
index f08979a..dd8842b 100644
--- a/src/Games/Logic/PuzzleFigures.cs
+++ b/src/Games/Logic/PuzzleFigures.cs
@@ -113,7 +113,7 @@ namespace gbrainy.Games.Logic
 
 			base.Draw (gr, area_width, area_height, rtl);
 
-			for (int i = 0; i < (DrawAnswer ? 6 : 5) ; i++)
+			for (int i = 0; i < (Answer.Draw ? 6 : 5) ; i++)
 			{
 				element = random_indices [i];
 				y = DrawAreaY;
@@ -139,7 +139,7 @@ namespace gbrainy.Games.Logic
 				x+= figure_width + space_width;
 			}
 
-			if (DrawAnswer == false) {
+			if (Answer.Draw == false) {
 				y = DrawAreaY;
 				gr.Save ();
 				gr.SetPangoFontSize (0.1);
diff --git a/src/Games/Logic/PuzzleFourSided.cs b/src/Games/Logic/PuzzleFourSided.cs
index a371a7a..1f4ca49 100644
--- a/src/Games/Logic/PuzzleFourSided.cs
+++ b/src/Games/Logic/PuzzleFourSided.cs
@@ -90,7 +90,7 @@ namespace gbrainy.Games.Logic
 				gr.Stroke ();
 			}
 
-			if (DrawAnswer == false)
+			if (Answer.Draw == false)
 				return;
 
 			// References
diff --git a/src/Games/Logic/PuzzleSquareSheets.cs b/src/Games/Logic/PuzzleSquareSheets.cs
index f2f1af6..d3271b9 100644
--- a/src/Games/Logic/PuzzleSquareSheets.cs
+++ b/src/Games/Logic/PuzzleSquareSheets.cs
@@ -73,7 +73,7 @@ namespace gbrainy.Games.Logic
 			gr.LineTo (x + 0.3, y + height - 0.1);  // Second vertical
 			gr.Stroke ();
 
-			if (DrawAnswer == false)
+			if (Answer.Draw == false)
 				return;
 
 			gr.LineTo (x + 0.04, y + 0.06);
diff --git a/src/Games/Logic/PuzzleTriangles.cs b/src/Games/Logic/PuzzleTriangles.cs
index 6b943bf..59bf08d 100644
--- a/src/Games/Logic/PuzzleTriangles.cs
+++ b/src/Games/Logic/PuzzleTriangles.cs
@@ -85,7 +85,7 @@ namespace gbrainy.Games.Logic
 			gr.LineTo (x + witdh, y);
 			gr.Stroke ();
 
-			if (DrawAnswer == false)
+			if (Answer.Draw == false)
 				return;
 
 			// References
diff --git a/src/Games/Memory/MemoryFigures.cs b/src/Games/Memory/MemoryFigures.cs
index 499c91b..8c4bc1a 100644
--- a/src/Games/Memory/MemoryFigures.cs
+++ b/src/Games/Memory/MemoryFigures.cs
@@ -155,7 +155,7 @@ namespace gbrainy.Games.Memory
 		{
 			gr.Color = new Color (DefaultDrawingColor.R, DefaultDrawingColor.G, DefaultDrawingColor.B, 1);
 
-			if (DrawAnswer ==  true) {
+			if (Answer.Draw ==  true) {
 				DrawAllFigures (gr, start_x_ans, start_y, area_width, area_height);
 				return;
 			}
diff --git a/src/Games/Memory/MemoryFiguresAndText.cs b/src/Games/Memory/MemoryFiguresAndText.cs
index 97b7f21..26f360d 100644
--- a/src/Games/Memory/MemoryFiguresAndText.cs
+++ b/src/Games/Memory/MemoryFiguresAndText.cs
@@ -116,7 +116,7 @@ namespace gbrainy.Games.Memory
 			int pos = 0;
 			gr.Color = new Color (DefaultDrawingColor.R, DefaultDrawingColor.G, DefaultDrawingColor.B, 1);
 
-			if (DrawAnswer ==  true) {
+			if (Answer.Draw ==  true) {
 				DrawAllFigures (gr, start_x_ans, start_y, area_width, area_height);
 				return;
 			}
diff --git a/src/Games/Memory/MemoryIndications.cs b/src/Games/Memory/MemoryIndications.cs
index 18e0baf..0915589 100644
--- a/src/Games/Memory/MemoryIndications.cs
+++ b/src/Games/Memory/MemoryIndications.cs
@@ -314,7 +314,7 @@ namespace gbrainy.Games.Memory
 		{
 			base.DrawObjectToMemorize (gr, area_width, area_height, rtl);
 
-			if (DrawAnswer == false) {
+			if (Answer.Draw == false) {
 				for (int i = 0; i < indications.Length; i++)
 				{
 					gr.MoveTo (0.3, 0.2 + i * 0.08);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]