gbrainy r480 - in trunk: . sample_extensions sample_extensions/Calculation sample_extensions/Logic sample_extensions/Memory src



Author: jmas
Date: Tue Dec 23 16:54:10 2008
New Revision: 480
URL: http://svn.gnome.org/viewvc/gbrainy?rev=480&view=rev

Log:
Mono.addin extensions support

Added:
   trunk/sample_extensions/
   trunk/sample_extensions/Calculation/
   trunk/sample_extensions/Calculation/CalculationSample.addin.xml
   trunk/sample_extensions/Calculation/CalculationSample.cs
   trunk/sample_extensions/Logic/   (props changed)
   trunk/sample_extensions/Logic/PuzzleSample.addin.xml   (contents, props changed)
   trunk/sample_extensions/Logic/PuzzleSample.cs   (contents, props changed)
   trunk/sample_extensions/Memory/
   trunk/sample_extensions/Memory/MemorySample.addin.xml
   trunk/sample_extensions/Memory/MemorySample.cs
   trunk/sample_extensions/README
Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/src/ChangeLog
   trunk/src/Defines.cs.in
   trunk/src/GameManager.cs
   trunk/src/Makefile.am
   trunk/src/gbrainy.cs
   trunk/src/gbrainy.glade

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Tue Dec 23 16:54:10 2008
@@ -1,4 +1,4 @@
-AC_INIT(gbrainy, 1.00)
+AC_INIT(gbrainy, 1.02)
 AC_CONFIG_SRCDIR(src/gbrainy.cs)
 
 AM_CONFIG_HEADER(config.h)
@@ -54,15 +54,15 @@
 
 GTKSHARP_REQUIRED=2.8
 MONO_REQUIRED=1.1.7
+MONO_ADDINS=0.3
 
 if ! pkg-config --atleast-version=2.10 gtk-sharp-2.0; then
-   AC_MSG_RESULT([GTK_2_8 defined])
    CSC_DEFINES="$CSC_DEFINES -d:GTK_2_8"
+   enable_gtk_28="true"
 else
-  AC_MSG_RESULT([GTK_2_8 not defined])
+   enable_gtk_28="false"
 fi
 
-AC_SUBST(CSC_DEFINES)
 
 PKG_CHECK_MODULES(GBRAINY_CORE, mono >= $MONO_REQUIRED)
 
@@ -73,8 +73,31 @@
 	glade-sharp-2.0 >= $GTKSHARP_REQUIRED)
 AC_SUBST(GBRAINY_LIBS)
 
+AC_ARG_ENABLE(addins, AC_HELP_STRING([--disable-addins], [Disable mono-addins support]), , enable_addins="yes")
+
+enable_addins_sharp="${enable_addins}"
+
+PKG_CHECK_MODULES(MONO_ADDINS,
+	mono-addins >= $MONO_ADDINS
+	mono-addins-setup >= $MONO_ADDINS
+	mono-addins-gui >= $MONO_ADDINS,
+	enable_addins_sharp="$enable_addins_sharp", enable_addins_sharp=no)
+
+if test "x$enable_addins" = "xyes" -a "x$enable_addins_sharp" = "xno"; then
+	AC_MSG_ERROR([mono-addins was not found or is not up to date. Please install mono-addins of at least version $MONO_ADDINS, or disable mono-addins support by --disable-addins])
+fi
+
+if test "x$enable_addins_sharp" = "xyes"; then
+	AC_SUBST(MONO_ADDINS_LIBS)
+	CSC_DEFINES="$CSC_DEFINES -d:MONO_ADDINS"
+fi
+
+AM_CONDITIONAL(ENABLE_ADDINS, test "x$enable_addins_sharp" = "xyes")
+
 PKG_CHECK_MODULES(GBRAINY_CHECK, librsvg-2.0)
 
+AC_SUBST(CSC_DEFINES)
+
 dnl -- Intl
 
 GETTEXT_PACKAGE=gbrainy
@@ -102,7 +125,6 @@
 AC_SUBST(GNOME_ICON_THEME_PREFIX)
 
 
-
 AC_OUTPUT([
 src/Defines.cs
 src/AssemblyInfo.cs
@@ -111,3 +133,6 @@
 src/Makefile
 data/Makefile
 ])
+
+echo "Support for older GTK:  ${enable_gtk_28}"
+echo "Mono-addins:            ${enable_addins_sharp}"

Added: trunk/sample_extensions/Calculation/CalculationSample.addin.xml
==============================================================================
--- (empty file)
+++ trunk/sample_extensions/Calculation/CalculationSample.addin.xml	Tue Dec 23 16:54:10 2008
@@ -0,0 +1,17 @@
+<Addin namespace="gbrainy"
+	version="1.00"
+	name="CalculationSample"
+	description="Calculation game Sample"
+	author="Jordi Mas"
+	url=""
+	defaultEnabled="true"
+	category="Calculation">
+
+	<Dependencies>
+		<Addin id="gbrainy" version="1.00"/>
+	</Dependencies>
+
+	<Extension path="/gbrainy/games/calculation">
+		<Calculation type="CalculationSample" />
+	</Extension>
+</Addin>

Added: trunk/sample_extensions/Calculation/CalculationSample.cs
==============================================================================
--- (empty file)
+++ trunk/sample_extensions/Calculation/CalculationSample.cs	Tue Dec 23 16:54:10 2008
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2007-2008 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
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+using System;
+using Cairo;
+using System.Text;
+using Mono.Unix;
+
+public class CalculationSample : Game
+{
+	private int number_a, number_b;
+	private int op1, op2, max_operand;
+
+	public override string Name {
+		get {return Catalog.GetString ("Calculation sample");}
+	}
+
+	public override Types Type {
+		get { return Game.Types.MathTrainer;}
+	}
+
+	public override string Question {
+		get {return String.Format (Catalog.GetString ("Which two numbers when added are {0} and when multiplied are {1}?"), op1, op2);} 
+	}
+
+	public override void Initialize ()
+	{	
+		switch (CurrentDifficulty) {
+		case Difficulty.Easy:
+			max_operand = 8;
+			break;
+		case Difficulty.Medium:
+			max_operand = 10;
+			break;
+		case Difficulty.Master:
+			max_operand = 15;
+			break;
+		}
+
+		number_a = 5 + random.Next (max_operand);
+		number_b = 3 + random.Next (max_operand);
+
+		op1 = number_a + number_b;
+		op2 = number_a * number_b;
+
+		right_answer = String.Format (Catalog.GetString ("{0} and {1}"), number_a, number_b);
+	}
+
+	public override void Draw (CairoContextEx gr, int area_width, int area_height)
+	{	
+		double x = DrawAreaX + 0.1;
+
+		base.Draw (gr, area_width, area_height);
+
+		gr.SetPangoLargeFontSize ();
+
+		gr.MoveTo (x, DrawAreaY + 0.22);
+		gr.ShowPangoText (String.Format (Catalog.GetString ("number1 + number2 = {0}"), op1));
+		
+		gr.MoveTo (x, DrawAreaY + 0.44);
+		gr.ShowPangoText (String.Format (Catalog.GetString ("number1 * number2 = {0}"), op2));
+
+		gr.Color = new Color (0.9, 0.9, 0.9);
+		gr.DrawTextCentered (0.5, DrawAreaY, String.Format (Catalog.GetString ("This is an extension sample")));
+	}
+
+	public override bool CheckAnswer (string answer)
+	{	
+		string num_a = string.Empty;
+		string num_b = string.Empty;
+		bool first = true;
+		
+		for (int c = 0; c < answer.Length; c++)
+		{
+			if (answer[c] < '0' || answer[c] > '9') {
+				first = false;
+				continue;
+			}
+			
+			if (first == true)
+				num_a += answer[c];
+			else
+				num_b += answer[c];
+		}
+
+		try {
+			if (Int32.Parse (num_a) == number_a && Int32.Parse (num_b) == number_b ||
+				Int32.Parse (num_b) == number_a && Int32.Parse (num_a) == number_b)
+				return true;
+		}
+
+		catch (FormatException) {
+			return false;
+		}
+	
+		return false;
+	}
+}

Added: trunk/sample_extensions/Logic/PuzzleSample.addin.xml
==============================================================================
--- (empty file)
+++ trunk/sample_extensions/Logic/PuzzleSample.addin.xml	Tue Dec 23 16:54:10 2008
@@ -0,0 +1,17 @@
+<Addin namespace="gbrainy"
+	version="1.00"
+	name="Puzzle Sample"
+	description="Puzzle Sample description"
+	author="Jordi Mas"
+	url=""
+	defaultEnabled="true"
+	category="Logic">
+
+	<Dependencies>
+		<Addin id="gbrainy" version="1.00"/>
+	</Dependencies>
+
+	<Extension path="/gbrainy/games/logic">
+		<Logic type="PuzzleSample" />
+	</Extension>
+</Addin>

Added: trunk/sample_extensions/Logic/PuzzleSample.cs
==============================================================================
--- (empty file)
+++ trunk/sample_extensions/Logic/PuzzleSample.cs	Tue Dec 23 16:54:10 2008
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2008 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
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+using Cairo;
+using Mono.Unix;
+using System;
+
+public class PuzzleSample : Game
+{
+	public override string Name {
+		get {return Catalog.GetString ("Puzzle sample");}
+	}
+
+	public override string Question {
+		get {return Catalog.GetString ("In a party all the people is introduced to the rest. There are 28 handeshakes. How many people is in the party?");} 
+	}
+
+	public override void Initialize ()
+	{
+		right_answer = "8";
+	}
+
+	public override void Draw (CairoContextEx gr, int area_width, int area_height)
+	{
+		base.Draw (gr, area_width, area_height);
+
+		gr.Color = new Color (0.4, 0.4, 0.4);
+		gr.DrawTextCentered (0.5, DrawAreaY, String.Format (Catalog.GetString ("This is an extension sample")));
+	}
+}

Added: trunk/sample_extensions/Memory/MemorySample.addin.xml
==============================================================================
--- (empty file)
+++ trunk/sample_extensions/Memory/MemorySample.addin.xml	Tue Dec 23 16:54:10 2008
@@ -0,0 +1,17 @@
+<Addin namespace="gbrainy"
+	version="1.00"
+	name="MemorySample"
+	description="Memory game Sample"
+	author="Jordi Mas"
+	url=""
+	defaultEnabled="true"
+	category="Memory">
+
+	<Dependencies>
+		<Addin id="gbrainy" version="1.00"/>
+	</Dependencies>
+
+	<Extension path="/gbrainy/games/memory">
+		<Memory type="MemorySample" />
+	</Extension>
+</Addin>

Added: trunk/sample_extensions/Memory/MemorySample.cs
==============================================================================
--- (empty file)
+++ trunk/sample_extensions/Memory/MemorySample.cs	Tue Dec 23 16:54:10 2008
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2007-2008 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
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+using System;
+using Cairo;
+using Mono.Unix;
+using System.Timers;
+using System.Collections.Generic;
+
+public class MemorySample : Memory
+{
+	ArrayListIndicesRandom animals_order;
+	List <string> animals;
+	int showed;
+	int answer;
+
+	public override string Name {
+		get {return Catalog.GetString ("Memory sample");}
+	}
+
+	public override string MemoryQuestion {
+		get { 
+			return String.Format (Catalog.GetString ("There is a missing animal name from the previous list. Which one is missing?"));}
+	}
+
+	public override void Initialize ()
+	{
+		int tmp;
+		animals = new List <string> ();
+
+		animals.Add (Catalog.GetString ("dog"));
+		animals.Add (Catalog.GetString ("cat"));
+		animals.Add (Catalog.GetString ("rat"));
+		animals.Add (Catalog.GetString ("bird"));
+		animals.Add (Catalog.GetString ("sardine"));
+		animals.Add (Catalog.GetString ("trout"));
+		animals.Add (Catalog.GetString ("monkfish"));
+		animals.Add (Catalog.GetString ("cod"));
+		animals.Add (Catalog.GetString ("salmon"));
+
+		switch (CurrentDifficulty) {
+		case Difficulty.Easy:
+			showed = 4;
+			break;
+		case Difficulty.Medium:
+			showed = 6;
+			break;
+		case Difficulty.Master:
+			showed = 8;
+			break;
+		}
+
+		animals_order = new ArrayListIndicesRandom (animals.Count);
+		animals_order.Initialize ();
+		answer = random.Next (showed);
+		tmp = animals_order [answer];
+		right_answer = animals [tmp];
+		base.Initialize ();
+	}
+	
+	public override void DrawPossibleAnswers (CairoContextEx gr, int area_width, int area_height)
+	{
+		double x= DrawAreaX + 0.125, y = DrawAreaY + 0.1;
+		int cnt = 0;
+
+		for (int i = 0; i < showed; i++)
+		{
+			if (i == answer)
+				continue;
+
+			gr.MoveTo (x, y);
+			gr.ShowPangoText (animals[animals_order[i]]);
+			gr.Stroke ();
+
+			if ((cnt + 1) % 3 == 0) {
+				y += 0.2;
+				x = DrawAreaX + 0.125;
+			} else {
+				x+= 0.25;
+			}
+			cnt++;
+		}
+
+		gr.Color = new Color (0.9, 0.9, 0.9);
+		gr.DrawTextCentered (0.5, DrawAreaY, String.Format (Catalog.GetString ("This is an extension sample")));
+	}
+	
+	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);
+	}
+	
+	void DrawObject (CairoContextEx gr, int area_width, int area_height)
+	{
+		double x= DrawAreaX + 0.125, y = DrawAreaY + 0.1;
+		for (int i = 0; i < showed; i++)
+		{
+			gr.MoveTo (x, y);
+			gr.ShowPangoText (animals[animals_order[i]]);
+			gr.Stroke ();
+			
+			if ((i + 1) % 3 == 0) {
+				y += 0.2;
+				x = DrawAreaX + 0.125;
+			} else {
+				x+= 0.25;
+			}
+		}
+	}
+}
+

Added: trunk/sample_extensions/README
==============================================================================
--- (empty file)
+++ trunk/sample_extensions/README	Tue Dec 23 16:54:10 2008
@@ -0,0 +1,3 @@
+gbrainy sample extensions
+
+See http://live.gnome.org/gbrainy/Extensions for more details

Modified: trunk/src/Defines.cs.in
==============================================================================
--- trunk/src/Defines.cs.in	(original)
+++ trunk/src/Defines.cs.in	Tue Dec 23 16:54:10 2008
@@ -18,7 +18,6 @@
  */
 
 using System;
-using System.Reflection;
 
 public class Defines
 {

Modified: trunk/src/GameManager.cs
==============================================================================
--- trunk/src/GameManager.cs	(original)
+++ trunk/src/GameManager.cs	Tue Dec 23 16:54:10 2008
@@ -20,10 +20,17 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using Mono.Posix;
+
+#if MONO_ADDINS
+using Mono.Addins;
+using Mono.Addins.Setup;
+#endif
+
 
 public class GameManager
 {
-	static Type[] LogicPuzzles = new Type[] 
+	static Type[] LogicPuzzlesInternal = new Type[] 
 	{
 		typeof (PuzzleMatrixNumbers),
 		typeof (PuzzleSquares),
@@ -64,7 +71,7 @@
 		typeof (PuzzleLargerShape),	
 	};
 
-	static Type[] CalculationTrainers = new Type[] 
+	static Type[] CalculationTrainersInternal = new Type[] 
 	{
 		typeof (CalculationArithmetical),
 		typeof (CalculationGreatestDivisor),
@@ -74,7 +81,7 @@
 		typeof (CalculationFractions),
 	};
 
-	static Type[] MemoryTrainers = new Type[] 
+	static Type[] MemoryTrainersInternal = new Type[] 
 	{
 		typeof (MemoryColouredFigures),
 		typeof (MemoryFiguresNumbers),
@@ -86,24 +93,32 @@
 		typeof (MemoryNumbers),
 	};
 
-	private GameSession.Types game_type;
-	private ArrayListIndicesRandom list;
-	private IEnumerator enumerator;
-	private List <Type> games;
-	private Game.Difficulty difficulty;
-
-	static GameManager ()
-	{
-		Console.WriteLine ("Games registered: {0}: {1} logic puzzles, {2} math trainers, {3} memory trainers", 
-			LogicPuzzles.Length + CalculationTrainers.Length + MemoryTrainers.Length,
-			LogicPuzzles.Length, CalculationTrainers.Length, MemoryTrainers.Length);
-	}
-
+	bool once;
+	GameSession.Types game_type;
+	ArrayListIndicesRandom list;
+	IEnumerator enumerator;
+	List <Type> games;
+	Game.Difficulty difficulty;
+	List <Type> LogicPuzzles;
+	List <Type> CalculationTrainers;
+	List <Type> MemoryTrainers;
+	
 	public GameManager ()
 	{
 		game_type = GameSession.Types.None;
 		difficulty = Game.Difficulty.Medium;
 		games = new List <Type> ();
+		LogicPuzzles = new List <Type> (LogicPuzzlesInternal);
+		CalculationTrainers = new List <Type> (CalculationTrainersInternal);
+		MemoryTrainers = new List <Type> (MemoryTrainersInternal);
+		LoadPlugins ();
+
+		if (once == false) {
+			once = true;
+			Console.WriteLine ("Games registered: {0}: {1} logic puzzles, {2} math trainers, {3} memory trainers", 
+				LogicPuzzles.Count + CalculationTrainers.Count + MemoryTrainers.Count,
+				LogicPuzzles.Count, CalculationTrainers.Count, MemoryTrainers.Count);
+		}
 		//GeneratePDF ();
 	}
 
@@ -131,16 +146,16 @@
 	// Used from CustomGameDialog only
 	public Type[] CustomGames {
 		get { 
-			Type[] list = new Type [LogicPuzzles.Length + CalculationTrainers.Length + MemoryTrainers.Length];
+			Type[] list = new Type [LogicPuzzles.Count + CalculationTrainers.Count + MemoryTrainers.Count];
 			int idx = 0;
 
-			for (int i = 0; i < LogicPuzzles.Length; i++, idx++)
+			for (int i = 0; i < LogicPuzzles.Count; i++, idx++)
 				list[idx] = LogicPuzzles [i];
 
-			for (int i = 0; i < CalculationTrainers.Length; i++, idx++)
+			for (int i = 0; i < CalculationTrainers.Count; i++, idx++)
 				list[idx] = CalculationTrainers [i];
 
-			for (int i = 0; i < MemoryTrainers.Length; i++, idx++)
+			for (int i = 0; i < MemoryTrainers.Count; i++, idx++)
 				list[idx] = MemoryTrainers [i];
 
 			return list;
@@ -155,7 +170,50 @@
 		}
 	}
 
-	private void BuildGameList ()
+	void LoadPlugins ()
+	{
+
+#if MONO_ADDINS
+		try {
+			ExtensionNodeList addins;
+			Game game;
+			string dir = System.IO.Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "gbrainy");
+		
+			AddinManager.Initialize (dir);
+			Console.WriteLine ("Pluggin database:" + dir);
+			AddinManager.Registry.Update (null);
+			SetupService setupService = new SetupService (AddinManager.Registry);
+
+			addins = AddinManager.GetExtensionNodes ("/gbrainy/games/logic");
+			foreach (TypeExtensionNode node in addins) {
+				game = (Game) node.CreateInstance ();
+				Console.WriteLine ("Loading external logic game: {0}", game);
+				LogicPuzzles.Add (game.GetType ());
+			}
+		
+			addins = AddinManager.GetExtensionNodes ("/gbrainy/games/memory");
+			foreach (TypeExtensionNode node in addins) {
+				game = (Game) node.CreateInstance ();
+				Console.WriteLine ("Loading external memory game: {0}", game);
+				MemoryTrainers.Add (game.GetType ());
+			}
+
+			addins = AddinManager.GetExtensionNodes ("/gbrainy/games/calculation");
+			foreach (TypeExtensionNode node in addins) {
+				game = (Game) node.CreateInstance ();
+				Console.WriteLine ("Loading external calculation game: {0}", game);
+				CalculationTrainers.Add (game.GetType ());
+			}
+		}
+		catch (Exception e)
+		{
+			Console.WriteLine (String.Format ("Exception {0} when loading the plugins", e));
+		}
+#endif
+	}
+
+
+	void BuildGameList ()
 	{
 		if (GameType == GameSession.Types.Custom)
 			return;
@@ -167,23 +225,23 @@
 		if ((game_type & GameSession.Types.AllGames) == GameSession.Types.AllGames) {
 			
 			int idx_cal = 0, idx_mem = 0;
-			ArrayListIndicesRandom idx_logic = new ArrayListIndicesRandom (LogicPuzzles.Length);
-			ArrayListIndicesRandom idx_memory = new ArrayListIndicesRandom (MemoryTrainers.Length);
-			ArrayListIndicesRandom idx_calculation = new ArrayListIndicesRandom (CalculationTrainers.Length);
+			ArrayListIndicesRandom idx_logic = new ArrayListIndicesRandom (LogicPuzzles.Count);
+			ArrayListIndicesRandom idx_memory = new ArrayListIndicesRandom (MemoryTrainers.Count);
+			ArrayListIndicesRandom idx_calculation = new ArrayListIndicesRandom (CalculationTrainers.Count);
 
 			games.Clear ();
 			idx_memory.Initialize ();
 			idx_logic.Initialize ();
 			idx_calculation.Initialize ();
 
-			for (int i = 0; i < LogicPuzzles.Length; i++, idx_mem++, idx_cal++) {
+			for (int i = 0; i < LogicPuzzles.Count; i++, idx_mem++, idx_cal++) {
 
-				if (idx_cal == CalculationTrainers.Length) {
+				if (idx_cal == CalculationTrainers.Count) {
 					idx_cal = 0;
 					idx_calculation.Initialize ();
 				}
 
-				if (idx_mem == MemoryTrainers.Length) {
+				if (idx_mem == MemoryTrainers.Count) {
 					idx_mem = 0;
 					idx_memory.Initialize ();
 				}
@@ -209,17 +267,17 @@
 		} else {
 
 			if ((game_type & GameSession.Types.LogicPuzzles) == GameSession.Types.LogicPuzzles) {
-				for (int i = 0; i < LogicPuzzles.Length; i++)
+				for (int i = 0; i < LogicPuzzles.Count; i++)
 					games.Add (LogicPuzzles [i]);
 			}
 
 			if ((game_type & GameSession.Types.CalculationTrainers) == GameSession.Types.CalculationTrainers) {
-				for (int i = 0; i < CalculationTrainers.Length; i++)
+				for (int i = 0; i < CalculationTrainers.Count; i++)
 					games.Add (CalculationTrainers [i]);
 			}
 
 			if ((game_type & GameSession.Types.MemoryTrainers) == GameSession.Types.MemoryTrainers) {
-				for (int i = 0; i < MemoryTrainers.Length; i++)
+				for (int i = 0; i < MemoryTrainers.Count; i++)
 					games.Add (MemoryTrainers [i]);
 			}
 		}
@@ -228,7 +286,7 @@
 		Initialize ();
 	}
 
-	private void Initialize ()
+	void Initialize ()
 	{
 		if ((game_type & GameSession.Types.AllGames) == GameSession.Types.AllGames) { // The game list has been already randomized
 			list.Clear ();

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Tue Dec 23 16:54:10 2008
@@ -74,6 +74,7 @@
 
 ASSEMBLIES = \
 	 $(GBRAINY_LIBS)    		\
+	 $(MONO_ADDINS_LIBS)    	\
 	-r:Mono.Cairo.dll		\
 	-r:Mono.Posix
 
@@ -87,7 +88,8 @@
 -resource:$(top_srcdir)/data/logic-games-32.png  \
 -resource:$(top_srcdir)/data/math-games-32.png  \
 -resource:$(top_srcdir)/data/memory-games-32.png  \
--resource:$(top_srcdir)/data/gbrainy.svg
+-resource:$(top_srcdir)/data/gbrainy.svg  \
+-resource:$(srcdir)/gbrainy.addin.xml
 
 gbrainydir = $(libdir)/gbrainy
 gbrainy_SCRIPTS = gbrainy.exe ../data/gbrainy.exe.config
@@ -104,6 +106,7 @@
 
 EXTRA_DIST =					\
 	gbrainy.glade \
+	$(srcdir)/gbrainy.addin.xml \
 	$(GBRAINY_CSDISTFILES)			
 
 

Modified: trunk/src/gbrainy.cs
==============================================================================
--- trunk/src/gbrainy.cs	(original)
+++ trunk/src/gbrainy.cs	Tue Dec 23 16:54:10 2008
@@ -28,6 +28,12 @@
 using System.Text;
 using System.Globalization;
 using System.Threading;
+using System.Diagnostics;
+
+#if MONO_ADDINS
+using Mono.Addins;
+using Mono.Addins.Setup;
+#endif
 
 public class gbrainy: Program
 {
@@ -43,6 +49,8 @@
 	[Glade.Widget] Gtk.Statusbar statusbar;
 	[Glade.Widget] Gtk.Toolbar toolbar;
 	[Glade.Widget] Gtk.Label label_answer;
+	[Glade.Widget] Gtk.Menu settings_menu;
+	[Glade.Widget] Gtk.Menu help_menu;
 	GameDrawingArea drawing_area;
 	GameSession session;
 	ToolButton pause_tbbutton;
@@ -143,6 +151,18 @@
 			}
 		}
 
+
+	#if MONO_ADDINS
+		Gtk.MenuItem item = new Gtk.MenuItem (Catalog.GetString ("Extensions"));
+		settings_menu.Append (item);
+		item.Activated += delegate (object sender, EventArgs ar) { Mono.Addins.Gui.AddinManagerWindow.Run (app_window);};
+
+		item = new Gtk.MenuItem (Catalog.GetString ("Develop your own puzzles for gbrainy"));
+		help_menu.Prepend (item);
+		item.Activated += delegate (object sender, EventArgs ar) { Process.Start ("http://live.gnome.org/gbrainy/Extensions";);};
+
+	#endif
+
 		drawing_vbox.Add (drawing_area);
 		app_window.IconName = "gbrainy";
 		app_window.ShowAll ();
@@ -158,36 +178,35 @@
 		//OnMemoryOnly (this, EventArgs.Empty); // temp
 	}
 
-		/* Taken from locale.h  */
-		[StructLayout (LayoutKind.Sequential)]
-		public struct lconv
-		{
-			public string decimal_point;
-			public string thousands_sep;		
-			public string grouping;
-			public string int_curr_symbol;
-			public string currency_symbol;
-			public string mon_decimal_point;
-			public string mon_thousands_sep;
-			public string mon_grouping;
-			public string positive_sign;
-			public string negative_sign;
-			char int_frac_digits;
-			char frac_digits;
-			char p_cs_precedes;
-			char p_sep_by_space;
-			char n_cs_precedes;
-			char n_sep_by_space;
-			char p_sign_posn;
-			char n_sign_posn;
-			char int_p_cs_precedes;
-			char int_p_sep_by_space;
-			char int_n_cs_precedes;
-			char int_n_sep_by_space;
-			char int_p_sign_posn;
-			char int_n_sign_posn;
-		}
-
+	/* Taken from locale.h  */
+	[StructLayout (LayoutKind.Sequential)]
+	public struct lconv
+	{
+		public string decimal_point;
+		public string thousands_sep;		
+		public string grouping;
+		public string int_curr_symbol;
+		public string currency_symbol;
+		public string mon_decimal_point;
+		public string mon_thousands_sep;
+		public string mon_grouping;
+		public string positive_sign;
+		public string negative_sign;
+		char int_frac_digits;
+		char frac_digits;
+		char p_cs_precedes;
+		char p_sep_by_space;
+		char n_cs_precedes;
+		char n_sep_by_space;
+		char p_sign_posn;
+		char n_sign_posn;
+		char int_p_cs_precedes;
+		char int_p_sep_by_space;
+		char int_n_cs_precedes;
+		char int_n_sep_by_space;
+		char int_p_sign_posn;
+		char int_n_sign_posn;
+	}
 
 	[DllImport("libc")]
 	static extern IntPtr localeconv ();

Modified: trunk/src/gbrainy.glade
==============================================================================
--- trunk/src/gbrainy.glade	(original)
+++ trunk/src/gbrainy.glade	Tue Dec 23 16:54:10 2008
@@ -198,7 +198,7 @@
 	      <property name="stock_item">GNOMEUIINFO_MENU_HELP_TREE</property>
 
 	      <child>
-		<widget class="GtkMenu" id="menuitem9_menu">
+		<widget class="GtkMenu" id="help_menu">
 
 		  <child>
 		    <widget class="GtkImageMenuItem" id="imagemenuitem3">



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