[gbrainy] Enhancements to XML game classes



commit 9e4275d13b33a310e8cd4535ef8d644ef9f7c1d0
Author: Jordi Mas <jmas softcatala org>
Date:   Sun Jun 6 16:59:30 2010 +0200

    Enhancements to XML game classes

 data/Makefile.am                    |    8 +++++++-
 po/POTFILES.in                      |    1 +
 src/Core/Main/Xml/GameXml.cs        |   20 +++++++++++++-------
 src/Core/Main/Xml/GameXmlFactory.cs |   14 ++++++++------
 4 files changed, 29 insertions(+), 14 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 2e02710..70b4e5d 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -42,7 +42,10 @@ tango_icons = 				\
 
 
 analogies_DATA = \
-	verbal_analogies.xml
+	verbal_analogies.xml \
+	games.xml \
+	game-graphics/clock.svg \
+	game-graphics/family.svg
 
 install-data-local:
 	@-$(mkinstalldirs) $(DESTDIR)$(hicolordir)/scalable/apps
@@ -55,6 +58,9 @@ install-data-local:
 	$(INSTALL_DATA) $(srcdir)/app-graphics/gbrainy.png $(DESTDIR)$(hicolordir)/48x48/apps/gbrainy.png
 	@-$(mkinstalldirs) $(DESTDIR)$(images)
 	$(INSTALL_DATA) $(srcdir)/verbal_analogies.xml $(DESTDIR)$(images)/verbal_analogies.xml
+	$(INSTALL_DATA) $(srcdir)/games.xml $(DESTDIR)$(images)/games.xml
+	$(INSTALL_DATA) $(srcdir)/game-graphics/clock.svg $(DESTDIR)$(images)/clock.svg
+	$(INSTALL_DATA) $(srcdir)/game-graphics/family.svg $(DESTDIR)$(images)/family.svg
 
 gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
 
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0674540..d442a2e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,3 +1,4 @@
+data/games.xml
 data/verbal_analogies.xml
 data/gbrainy.desktop.in
 src/Core/Views/CountDownView.cs
diff --git a/src/Core/Main/Xml/GameXml.cs b/src/Core/Main/Xml/GameXml.cs
index 10058a7..fac1feb 100644
--- a/src/Core/Main/Xml/GameXml.cs
+++ b/src/Core/Main/Xml/GameXml.cs
@@ -27,7 +27,7 @@ namespace gbrainy.Core.Main
 {
 	public class GameXml : Game
 	{
-		// Every GameXml instance is capable of locating any XML defined game 
+		// Every GameXml instance is capable of locating any XML defined game
 		// This struct translates from a Variant that is global to all games
 		// to a specific game + variant
 		public struct DefinitionLocator
@@ -67,27 +67,33 @@ namespace gbrainy.Core.Main
 		public override string Question {
 			get {
 				if (game.Variants.Count > 0 && game.Variants[current.Variant].Question != null)
-					return game.Variants[current.Variant].Question;
+					return Catalog.GetString (game.Variants[current.Variant].Question);
 				else
-					return game.Question;
+					return Catalog.GetString (game.Question);
 			}
 		}
 
 		public override string Rationale {
 			get {
 				if (game.Variants.Count > 0 && game.Variants[current.Variant].Rationale != null)
-					return game.Variants[current.Variant].Rationale;
+					return Catalog.GetString (game.Variants[current.Variant].Rationale);
 				else
-					return game.Rationale;
+					if (String.IsNullOrEmpty (game.Rationale) == false)
+						return Catalog.GetString (game.Rationale);
+					else
+						return null;
 			}
 		}
 
 		public override string Tip {
 			get {
 				if (game.Variants.Count > 0 && game.Variants[current.Variant].Tip != null)
-					return game.Variants[current.Variant].Tip;
+					return Catalog.GetString (game.Variants[current.Variant].Tip);
 				else
-					return game.Tip;
+					if (String.IsNullOrEmpty (game.Tip) == false)
+						return Catalog.GetString (game.Tip);
+					else
+						return null;
 			}
 		}
 
diff --git a/src/Core/Main/Xml/GameXmlFactory.cs b/src/Core/Main/Xml/GameXmlFactory.cs
index 23a697b..5192c44 100644
--- a/src/Core/Main/Xml/GameXmlFactory.cs
+++ b/src/Core/Main/Xml/GameXmlFactory.cs
@@ -21,6 +21,7 @@ using System;
 using System.Xml;
 using System.IO;
 using System.Collections.Generic;
+using System.Globalization;
 
 using Mono.Unix;
 
@@ -114,27 +115,27 @@ namespace gbrainy.Core.Main
 
 						game.Image.Filename = reader.GetAttribute ("file");
 
-						str = reader.GetAttribute ("X");
+						str = reader.GetAttribute ("x");
 						if (String.IsNullOrEmpty (str) == false)
-							game.Image.X = Double.Parse (str);
+							game.Image.X = Double.Parse (str, CultureInfo.InvariantCulture);
 						else
 							game.Image.X = 0.1;
 
-						str = reader.GetAttribute ("Y");
+						str = reader.GetAttribute ("y");
 						if (String.IsNullOrEmpty (str) == false)
-							game.Image.Y = Double.Parse (str);
+							game.Image.Y = Double.Parse (str, CultureInfo.InvariantCulture);
 						else
 							game.Image.Y = 0.1;
 
 						str = reader.GetAttribute ("width");
 						if (String.IsNullOrEmpty (str) == false)
-							game.Image.Width = Double.Parse (str);
+							game.Image.Width = Double.Parse (str, CultureInfo.InvariantCulture);
 						else
 							game.Image.Width = 0.8;
 
 						str = reader.GetAttribute ("height");
 						if (String.IsNullOrEmpty (str) == false)
-							game.Image.Height = Double.Parse (str);
+							game.Image.Height = Double.Parse (str, CultureInfo.InvariantCulture);
 						else
 							game.Image.Height = 0.8;
 
@@ -159,6 +160,7 @@ namespace gbrainy.Core.Main
 							game.Rationale = reader.ReadElementString ();
 
 						break;
+					case "answer":
 					case "_answer":
 						if (reader.NodeType != XmlNodeType.Element)
 							break;



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