gbrainy r330 - trunk/src



Author: jmas
Date: Sat May 10 11:47:00 2008
New Revision: 330
URL: http://svn.gnome.org/viewvc/gbrainy?rev=330&view=rev

Log:
2008-05-10 Jordi Mas <jmas softcatala org>

	*  Preferences.cs: Preferences directory creation
	*  PlayerHistory.cs: Move to Save Method preferences directory creation



Modified:
   trunk/src/ChangeLog
   trunk/src/PlayerHistory.cs
   trunk/src/Preferences.cs

Modified: trunk/src/PlayerHistory.cs
==============================================================================
--- trunk/src/PlayerHistory.cs	(original)
+++ trunk/src/PlayerHistory.cs	Sat May 10 11:47:00 2008
@@ -72,9 +72,6 @@
 		history.memory_score = session.MemoryScore;
 		history.total_score = session.TotalScore;
 
-		if (!Directory.Exists (config_path))
-			Directory.CreateDirectory (config_path);
-
 		if (games.Count >= gbrainy.preferences.GetIntValue (Preferences.MaxStoredGamesKey))
 			games.RemoveAt (0);
 
@@ -86,6 +83,9 @@
 	{
 		try {
 
+			if (!Directory.Exists (config_path))
+				Directory.CreateDirectory (config_path);
+
 			using (FileStream str = File.Create (file))
 			{
 				XmlSerializer bf = new XmlSerializer (typeof (List <GameHistory>));

Modified: trunk/src/Preferences.cs
==============================================================================
--- trunk/src/Preferences.cs	(original)
+++ trunk/src/Preferences.cs	Sat May 10 11:47:00 2008
@@ -72,7 +72,7 @@
 				TValue value = (TValue) value_serializer.Deserialize (reader);
 				reader.ReadEndElement();
 
-				this.Add(key, value);
+				this[key] = value; // already created in DefaultValues
 				reader.ReadEndElement();
 
 				reader.MoveToContent();
@@ -117,6 +117,10 @@
 	public void Save ()
 	{
 		try {
+
+			if (!Directory.Exists (config_path))
+				Directory.CreateDirectory (config_path);
+
 			XmlTextWriter writer = new XmlTextWriter (file, Encoding.UTF8);
 			writer.Formatting = Formatting.Indented;
 
@@ -167,7 +171,6 @@
 		}
 		catch (Exception)
 		{
-			
 		}
 	}
 	



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