gbrainy r510 - in trunk/src: . Dialogs MemoryGames PuzzleGames



Author: jmas
Date: Wed Feb 11 20:02:39 2009
New Revision: 510
URL: http://svn.gnome.org/viewvc/gbrainy?rev=510&view=rev

Log:
Fixes to correctness of definitions

Modified:
   trunk/src/ArrayListIndicesRandom.cs
   trunk/src/AssemblyInfo.cs.in
   trunk/src/CairoContextEx.cs
   trunk/src/ColorPalette.cs
   trunk/src/Defines.cs.in
   trunk/src/Dialogs/AboutDialog.cs
   trunk/src/Game.cs
   trunk/src/GameDrawingArea.cs
   trunk/src/GameSession.cs
   trunk/src/MemoryGames/MemoryColouredText.cs
   trunk/src/MemoryGames/MemoryIndications.cs
   trunk/src/Preferences.cs
   trunk/src/PuzzleGames/PuzzleBuildTriangle.cs
   trunk/src/PuzzleGames/PuzzleClocks.cs
   trunk/src/PuzzleGames/PuzzleCoverPercentage.cs
   trunk/src/PuzzleGames/PuzzleDivideCircle.cs
   trunk/src/PuzzleGames/PuzzleExtraCircle.cs
   trunk/src/PuzzleGames/PuzzleFigurePattern.cs
   trunk/src/PuzzleGames/PuzzleLines.cs
   trunk/src/PuzzleGames/PuzzleMissingSlice.cs
   trunk/src/PuzzleGames/PuzzleNextFigure.cs
   trunk/src/PuzzleGames/PuzzlePencil.cs
   trunk/src/PuzzleGames/PuzzleQuadrilaterals.cs
   trunk/src/PuzzleGames/PuzzleSquaresAndLetters.cs
   trunk/src/PuzzleGames/PuzzleTetris.cs
   trunk/src/SVGImage.cs
   trunk/src/gbrainy.cs

Modified: trunk/src/ArrayListIndicesRandom.cs
==============================================================================
--- trunk/src/ArrayListIndicesRandom.cs	(original)
+++ trunk/src/ArrayListIndicesRandom.cs	Wed Feb 11 20:02:39 2009
@@ -25,7 +25,7 @@
 //
 public class ArrayListIndicesRandom : List <int>
 {
-	protected Random random;
+	Random random;
 
 	public ArrayListIndicesRandom (int capacity) : base (capacity)
 	{

Modified: trunk/src/AssemblyInfo.cs.in
==============================================================================
--- trunk/src/AssemblyInfo.cs.in	(original)
+++ trunk/src/AssemblyInfo.cs.in	Wed Feb 11 20:02:39 2009
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Jordi Mas i HernÃndez <jmas softcatala org>
+ * Copyright (C) 2007-2009 Jordi Mas i HernÃndez <jmas softcatala org>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -18,12 +18,10 @@
  */
 
 using System.Reflection;
-using System.Runtime.CompilerServices;
-using Mono.Unix;
 
 [assembly: AssemblyVersion("@VERSION@")]
 [assembly: AssemblyTitle ("gbrainy")]
-[assembly: AssemblyCopyright ("(c)2007-2008 Jordi Mas")]
+[assembly: AssemblyCopyright ("(c)2007-2009 Jordi Mas")]
 [assembly: AssemblyDescription ("A brain teaser game for fun and keep your brain trained")]
 
 

Modified: trunk/src/CairoContextEx.cs
==============================================================================
--- trunk/src/CairoContextEx.cs	(original)
+++ trunk/src/CairoContextEx.cs	Wed Feb 11 20:02:39 2009
@@ -350,34 +350,30 @@
 
 	public void DrawImageFromAssembly (string  resource, double x, double y, double width, double height)
 	{
-		SVGImage image;
-
 		try {
-			image = new SVGImage (System.Reflection.Assembly.GetCallingAssembly (), resource);
+			using (SVGImage image = new SVGImage (System.Reflection.Assembly.GetCallingAssembly (), resource))
+			{
+				DrawImage (image, x, y, width, height);
+			}
 		}
 		catch (Exception)
 		{
 			return;
 		}
-
-		DrawImage (image, x, y, width, height);
-		image.Dispose ();
 	}
 
 	public void DrawImageFromFile (string filename, double x, double y, double width, double height)
 	{
-		SVGImage image;
-
 		try {
-			image = new SVGImage (filename);
+			using (SVGImage image = new SVGImage (filename))
+			{
+				DrawImage (image, x, y, width, height);
+			}
 		}
 		catch (Exception)
 		{
 			return;
 		}
-
-		DrawImage (image, x, y, width, height);
-		image.Dispose ();
 	}
 
 	void DrawImage (SVGImage image, double x, double y, double width, double height)

Modified: trunk/src/ColorPalette.cs
==============================================================================
--- trunk/src/ColorPalette.cs	(original)
+++ trunk/src/ColorPalette.cs	Wed Feb 11 20:02:39 2009
@@ -59,7 +59,7 @@
 		White=Last
 	};
 
-	private static string[] ColorName= new string[] {
+	private static readonly string[] ColorName= new string[] {
 		Catalog.GetString ("red"),
 		Catalog.GetString ("green"),
 		Catalog.GetString ("blue"),

Modified: trunk/src/Defines.cs.in
==============================================================================
--- trunk/src/Defines.cs.in	(original)
+++ trunk/src/Defines.cs.in	Wed Feb 11 20:02:39 2009
@@ -21,9 +21,9 @@
 
 public class Defines
 {
-	public static string VERSION = "@VERSION@";
+	public const string VERSION = "@VERSION@";
 	public const string GNOME_LOCALE_DIR = "@prefix@/share/locale";
-	public static string DATA_DIR = "@prefix@/share/games/gbrainy/";
+	public const string DATA_DIR = "@prefix@/share/games/gbrainy/";
 }
 
 

Modified: trunk/src/Dialogs/AboutDialog.cs
==============================================================================
--- trunk/src/Dialogs/AboutDialog.cs	(original)
+++ trunk/src/Dialogs/AboutDialog.cs	Wed Feb 11 20:02:39 2009
@@ -72,7 +72,7 @@
 		Response += delegate (object o, Gtk.ResponseArgs e) {Destroy ();};
 	}
 
-	Pixbuf LoadFromAssembly (string resource)
+	static Pixbuf LoadFromAssembly (string resource)
 	{
 		try {
 			return new Pixbuf (System.Reflection.Assembly.GetEntryAssembly (), resource);

Modified: trunk/src/Game.cs
==============================================================================
--- trunk/src/Game.cs	(original)
+++ trunk/src/Game.cs	Wed Feb 11 20:02:39 2009
@@ -52,7 +52,6 @@
 	protected Game ()
 	{
 		random = new Random ();
-		application = null;
 		draw_answer = false;
 		default_color = new Cairo.Color (0, 0, 0);
 		won = false;
@@ -226,7 +225,7 @@
 	public abstract void Initialize ();
 	public virtual void Finish () {}
 
-	public string GetPossibleAnswer (int answer)
+	static public string GetPossibleAnswer (int answer)
 	{
 		switch (answer) {
 			// Translators Note

Modified: trunk/src/GameDrawingArea.cs
==============================================================================
--- trunk/src/GameDrawingArea.cs	(original)
+++ trunk/src/GameDrawingArea.cs	Wed Feb 11 20:02:39 2009
@@ -70,7 +70,7 @@
 		}
 	}
 
-	private void DrawBand (CairoContextEx gr, double x, double y)
+	static void DrawBand (CairoContextEx gr, double x, double y)
 	{
 		gr.Save ();
 		gr.Rectangle (x, y, 1 - 0.06, 0.06);
@@ -135,7 +135,7 @@
 	}
 
 
-	public void DrawBar (CairoContextEx gr, double x, double y, double w, double h, double percentage)
+	static public void DrawBar (CairoContextEx gr, double x, double y, double w, double h, double percentage)
 	{
 		double per = percentage / 100;
 	

Modified: trunk/src/GameSession.cs
==============================================================================
--- trunk/src/GameSession.cs	(original)
+++ trunk/src/GameSession.cs	Wed Feb 11 20:02:39 2009
@@ -24,6 +24,7 @@
 
 public class GameSession
 {
+	[Flags]
 	public enum Types
 	{	
 		None			= 0,
@@ -325,7 +326,7 @@
 		Application.Invoke (delegate {	app.UpdateStatusBar (); } );
 	}
 
-	private string TimeSpanToStr (TimeSpan time)
+	static private string TimeSpanToStr (TimeSpan time)
 	{
 		string fmt = time.ToString ();
 		int i = fmt.IndexOf ('.');
@@ -334,7 +335,5 @@
 
 		return fmt;
 	}
-
-
 }
 

Modified: trunk/src/MemoryGames/MemoryColouredText.cs
==============================================================================
--- trunk/src/MemoryGames/MemoryColouredText.cs	(original)
+++ trunk/src/MemoryGames/MemoryColouredText.cs	Wed Feb 11 20:02:39 2009
@@ -63,10 +63,10 @@
 	public override void DrawObjectToMemorize (CairoContextEx gr, int area_width, int area_height)
 	{
 		base.DrawObjectToMemorize (gr, area_width, area_height);
-		DrawObject (gr, area_width, area_height);
+		DrawObject (gr);
 	}
 
-	private void DrawObject (CairoContextEx gr, int area_width, int area_height)
+	private void DrawObject (CairoContextEx gr)
 	{
 		palette.Alpha=alpha;
 

Modified: trunk/src/MemoryGames/MemoryIndications.cs
==============================================================================
--- trunk/src/MemoryGames/MemoryIndications.cs	(original)
+++ trunk/src/MemoryGames/MemoryIndications.cs	Wed Feb 11 20:02:39 2009
@@ -243,7 +243,7 @@
 		return answer;
 	}
 
-	private void DrawPossibleAnswers (CairoContextEx gr, double x, double y, Indication[] indications)
+	private static void DrawPossibleAnswers (CairoContextEx gr, double x, double y, Indication[] indications)
 	{		
 		for (int i = 0; i < indications.Length - 1; i++)
 			indications[i].Draw (gr, ref x, ref y, indications[i + 1]);

Modified: trunk/src/Preferences.cs
==============================================================================
--- trunk/src/Preferences.cs	(original)
+++ trunk/src/Preferences.cs	Wed Feb 11 20:02:39 2009
@@ -26,21 +26,20 @@
 
 public class Preferences
 {
-	private string file, config_path;
-	private SerializableDictionary <string, string > properties;
-
-	static public string MemQuestionWarnKey = "MemQuestionWarn";
-	static public string MemQuestionTimeKey = "MemQuestionTime";
-	static public string DifficultyKey = "Difficulty";
-	static public string MinPlayedGamesKey = "MinPlayedGames";
-	static public string MaxStoredGamesKey = "MaxStoredGamesKey";
-	static public string Toolbar = "Toolbar";
-
-	static private string element_item = "item";
-	static private string element_key = "key";
-	static private string element_value = "value";
-	static private string element_collection = "collection";
+	string file, config_path;
+	SerializableDictionary <string, string > properties;
 
+	public const string MemQuestionWarnKey = "MemQuestionWarn";
+	public const string MemQuestionTimeKey = "MemQuestionTime";
+	public const string DifficultyKey = "Difficulty";
+	public const string MinPlayedGamesKey = "MinPlayedGames";
+	public const string MaxStoredGamesKey = "MaxStoredGamesKey";
+	public const string Toolbar = "Toolbar";
+
+	const string element_item = "item";
+	const string element_key = "key";
+	const string element_value = "value";
+	const string element_collection = "collection";
 
     	public class SerializableDictionary <TKey, TValue> : Dictionary<TKey, TValue>, IXmlSerializable
 	{

Modified: trunk/src/PuzzleGames/PuzzleBuildTriangle.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleBuildTriangle.cs	(original)
+++ trunk/src/PuzzleGames/PuzzleBuildTriangle.cs	Wed Feb 11 20:02:39 2009
@@ -94,7 +94,7 @@
 		right_answer = answers[0] + answers[1] + answers[2];
 	}
 
-	private void DrawFigure (CairoContextEx gr, double x, double y, Figures figure)
+	private static void DrawFigure (CairoContextEx gr, double x, double y, Figures figure)
 	{
 		switch (figure) {
 		case Figures.TriangleA:

Modified: trunk/src/PuzzleGames/PuzzleClocks.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleClocks.cs	(original)
+++ trunk/src/PuzzleGames/PuzzleClocks.cs	Wed Feb 11 20:02:39 2009
@@ -104,7 +104,7 @@
 
 	}	
 
-	public void DrawClock (CairoContextEx gr, double x, double y, int hand_short, int hand_large, bool draw_large)
+	static void DrawClock (CairoContextEx gr, double x, double y, int hand_short, int hand_large, bool draw_large)
 	{
 		double radius = figure_size / 2;
 		double x0, y0;

Modified: trunk/src/PuzzleGames/PuzzleCoverPercentage.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleCoverPercentage.cs	(original)
+++ trunk/src/PuzzleGames/PuzzleCoverPercentage.cs	Wed Feb 11 20:02:39 2009
@@ -70,7 +70,7 @@
 		right_answer = total.ToString ();
 	}
 
-	private void Fill (CairoContextEx gr, double x, double y, double w, double h)
+	private static void Fill (CairoContextEx gr, double x, double y, double w, double h)
 	{
 		gr.Rectangle (x, y, w, h);
 		gr.FillGradient (x, y, w, h);

Modified: trunk/src/PuzzleGames/PuzzleDivideCircle.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleDivideCircle.cs	(original)
+++ trunk/src/PuzzleGames/PuzzleDivideCircle.cs	Wed Feb 11 20:02:39 2009
@@ -63,7 +63,7 @@
 		}			
 	}
 
-	private void DrawAndConnectPoints (CairoContextEx gr, double x, double y, Circle[] circles, bool connect)
+	static private void DrawAndConnectPoints (CairoContextEx gr, double x, double y, Circle[] circles, bool connect)
 	{
 		double point_size = 0.01;
 		for (int i = 0; i < circles.Length; i++) {

Modified: trunk/src/PuzzleGames/PuzzleExtraCircle.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleExtraCircle.cs	(original)
+++ trunk/src/PuzzleGames/PuzzleExtraCircle.cs	Wed Feb 11 20:02:39 2009
@@ -85,7 +85,7 @@
 		right_answer = GetPossibleAnswer (ans_pos);
 	}
 
-	private void DrawSlice (CairoContextEx gr, double x, double y, double dg, Color color)
+	static private void DrawSlice (CairoContextEx gr, double x, double y, double dg, Color color)
 	{
 		double x1, y1, smallest_x, smallest_y, degrees;
 

Modified: trunk/src/PuzzleGames/PuzzleFigurePattern.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleFigurePattern.cs	(original)
+++ trunk/src/PuzzleGames/PuzzleFigurePattern.cs	Wed Feb 11 20:02:39 2009
@@ -78,7 +78,7 @@
 		gr.Stroke ();
 	}
 
-	private void DrawTwoLines (CairoContextEx gr, double x, double y, double size)
+	static void DrawTwoLines (CairoContextEx gr, double x, double y, double size)
 	{
 		gr.MoveTo (x, y);
 		gr.LineTo (x + size, y);
@@ -87,7 +87,7 @@
 		gr.Stroke ();
 	}
 
-	private void DrawCross (CairoContextEx gr, double x, double y, double size)
+	static void DrawCross (CairoContextEx gr, double x, double y, double size)
 	{
 		gr.MoveTo (x + size / 2, y);
 		gr.LineTo (x + size / 2, y + size);

Modified: trunk/src/PuzzleGames/PuzzleLines.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleLines.cs	(original)
+++ trunk/src/PuzzleGames/PuzzleLines.cs	Wed Feb 11 20:02:39 2009
@@ -72,7 +72,7 @@
 		right_answer = (fig1 + fig2).ToString ();
 	}
 
-	private void DrawLine (CairoContextEx gr, double x, double y, double w, double h)
+	static private void DrawLine (CairoContextEx gr, double x, double y, double w, double h)
 	{
 		gr.MoveTo (x, y);
 		gr.LineTo (x + w, y + h);

Modified: trunk/src/PuzzleGames/PuzzleMissingSlice.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleMissingSlice.cs	(original)
+++ trunk/src/PuzzleGames/PuzzleMissingSlice.cs	Wed Feb 11 20:02:39 2009
@@ -89,7 +89,7 @@
 		}
 	}
 
-	private void DrawSlice (CairoContextEx gr, double x, double y)
+	private static void DrawSlice (CairoContextEx gr, double x, double y)
 	{
 		double degrees, x1, y1;
 		

Modified: trunk/src/PuzzleGames/PuzzleNextFigure.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleNextFigure.cs	(original)
+++ trunk/src/PuzzleGames/PuzzleNextFigure.cs	Wed Feb 11 20:02:39 2009
@@ -77,7 +77,7 @@
 		}
 	}
 
-	private void DrawDiamon (CairoContextEx gr, double x, double y, CerclePosition cercles)
+	static private void DrawDiamon (CairoContextEx gr, double x, double y, CerclePosition cercles)
 	{	
 		double distance = 0.04;
 

Modified: trunk/src/PuzzleGames/PuzzlePencil.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzlePencil.cs	(original)
+++ trunk/src/PuzzleGames/PuzzlePencil.cs	Wed Feb 11 20:02:39 2009
@@ -54,7 +54,7 @@
 		}	
 	}
 
-	private void DrawTriangle (CairoContextEx gr, double x, double y)
+	static private void DrawTriangle (CairoContextEx gr, double x, double y)
 	{
 		gr.MoveTo (x + (figure_size / 2), y);
 		gr.LineTo (x, y + figure_size);
@@ -64,7 +64,7 @@
 		gr.Stroke ();	
 	}
 
-	private void DrawDiamon (CairoContextEx gr, double x, double y)
+	static private void DrawDiamon (CairoContextEx gr, double x, double y)
 	{
 		gr.MoveTo (x, y);
 		gr.LineTo (x - (figure_size / 2), y + (figure_size / 2));
@@ -75,7 +75,7 @@
 		gr.Stroke ();
 	}
 
-	private void DrawRectangleWithTriangles (CairoContextEx gr, double x, double y)
+	static private void DrawRectangleWithTriangles (CairoContextEx gr, double x, double y)
 	{
 		gr.Rectangle (x, y, figure_size, figure_size);
 		gr.Stroke ();	
@@ -93,7 +93,7 @@
 		gr.Stroke ();
 	}
 
-	private void DrawThreeTriangles (CairoContextEx gr, double x, double y)
+	static private void DrawThreeTriangles (CairoContextEx gr, double x, double y)
 	{
 		gr.MoveTo (x, y);
 		gr.LineTo (x, y + figure_size);
@@ -106,7 +106,7 @@
 		
 	}
 
-	private void DrawHouse (CairoContextEx gr, double x, double y)
+/*	private void DrawHouse (CairoContextEx gr, double x, double y)
 	{
 		gr.MoveTo (x, y + figure_size);
 		gr.LineTo (x, y + figure_size / 2);
@@ -117,11 +117,10 @@
 		gr.LineTo (x + figure_size, y + figure_size / 2);
 		gr.LineTo (x, y + figure_size);
 		gr.LineTo (x + figure_size, y + figure_size);
-		gr.Stroke ();
-		
-	}
+		gr.Stroke ();		
+	}*/
 
-	private void DrawRectangleWithCross (CairoContextEx gr, double x, double y)
+	static private void DrawRectangleWithCross (CairoContextEx gr, double x, double y)
 	{
 		gr.Rectangle (x, y, figure_size, figure_size);
 

Modified: trunk/src/PuzzleGames/PuzzleQuadrilaterals.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleQuadrilaterals.cs	(original)
+++ trunk/src/PuzzleGames/PuzzleQuadrilaterals.cs	Wed Feb 11 20:02:39 2009
@@ -70,7 +70,7 @@
 		}
 	}
 
-	private void DrawFigure (CairoContextEx gr, double x, double y, Figures figure)
+	static void DrawFigure (CairoContextEx gr, double x, double y, Figures figure)
 	{
 		switch (figure) {
 		case Figures.FigureA:

Modified: trunk/src/PuzzleGames/PuzzleSquaresAndLetters.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleSquaresAndLetters.cs	(original)
+++ trunk/src/PuzzleGames/PuzzleSquaresAndLetters.cs	Wed Feb 11 20:02:39 2009
@@ -66,7 +66,7 @@
 		characters[((figures - 1) * 4) + 3] = '?';
 	}
 
-	private string ToStr (char ch)
+	static string ToStr (char ch)
 	{
 		string s = string.Empty;
 		s+= ch;
@@ -106,7 +106,6 @@
 		DrawRectangleWithText (gr, x + figure_size + 0.05, y + 0.2 + figure_size, 8);
 			
 	}
-
 }
 
 

Modified: trunk/src/PuzzleGames/PuzzleTetris.cs
==============================================================================
--- trunk/src/PuzzleGames/PuzzleTetris.cs	(original)
+++ trunk/src/PuzzleGames/PuzzleTetris.cs	Wed Feb 11 20:02:39 2009
@@ -61,7 +61,7 @@
 		}
 	}
 
-	private void DrawQuestionFigures (CairoContextEx gr, double x, double y, int figure)
+	private static void DrawQuestionFigures (CairoContextEx gr, double x, double y, int figure)
 	{
 		switch (figure) {
 		case 0:
@@ -101,7 +101,7 @@
 		}
 	}
 
-	private void DrawAnswerFigures (CairoContextEx gr, double x, double y, int figure)
+	private static void DrawAnswerFigures (CairoContextEx gr, double x, double y, int figure)
 	{
 		switch (figure) {
 		case 0:

Modified: trunk/src/SVGImage.cs
==============================================================================
--- trunk/src/SVGImage.cs	(original)
+++ trunk/src/SVGImage.cs	Wed Feb 11 20:02:39 2009
@@ -44,7 +44,7 @@
 	static extern IntPtr rsvg_handle_new_from_data (byte[] data, int len, out int error);
 
 	[StructLayout(LayoutKind.Sequential)]
-	protected struct RsvgDimensionData
+	struct RsvgDimensionData
 	{
 	    	public int width;
 	    	public int height;
@@ -52,8 +52,8 @@
 		public double ex;
 	}
 
-	private RsvgDimensionData dimension;
-	private IntPtr handle;
+	RsvgDimensionData dimension;
+	IntPtr handle;
 
 	public SVGImage (System.Reflection.Assembly _assembly, string resource)
 	{
@@ -106,13 +106,24 @@
 		get { return dimension.height; }
 	}
 
+	~SVGImage ()
+	{
+		Dispose (false);
+	}
+
 	public void Dispose ()
 	{
+		Dispose (true);
+		System.GC.SuppressFinalize (this);
+	}
+
+	protected virtual void Dispose (bool disposing)
+	{
 		if (handle == IntPtr.Zero)
 			return;
 
 		rsvg_handle_free (handle);
-		handle = IntPtr.Zero;	
+		handle = IntPtr.Zero;
 	}
 
 	public void RenderToCairo (IntPtr cairo_surface)
@@ -121,4 +132,3 @@
 			rsvg_handle_render_cairo (handle, cairo_surface);
 	}
 }
-

Modified: trunk/src/gbrainy.cs
==============================================================================
--- trunk/src/gbrainy.cs	(original)
+++ trunk/src/gbrainy.cs	Wed Feb 11 20:02:39 2009
@@ -220,7 +220,7 @@
 	//
 	// See: https://bugzilla.novell.com/show_bug.cgi?id=420468
 	// 
-	private void FixLocaleInfo ()
+	static void FixLocaleInfo ()
 	{
 		IntPtr st = IntPtr.Zero;
 		lconv lv;



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