gnome-games r8538 - trunk/libgames-support



Author: chpe
Date: Thu Jan  8 23:44:38 2009
New Revision: 8538
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8538&view=rev

Log:
Get all backs from the pysol card theme's config.txt.

Modified:
   trunk/libgames-support/games-card-theme-pysol.c

Modified: trunk/libgames-support/games-card-theme-pysol.c
==============================================================================
--- trunk/libgames-support/games-card-theme-pysol.c	(original)
+++ trunk/libgames-support/games-card-theme-pysol.c	Thu Jan  8 23:44:38 2009
@@ -75,12 +75,14 @@
   char *name;
   char *base_path;
   char *ext;
-  char *back_filename;
   int version;
   int type;
   int n_cards;
   CardSize card_size;
   int card_delta;
+  char **backs;
+  int n_backs;
+  int default_back_index;
 } PySolConfigTxtData;
 
 static void
@@ -89,7 +91,7 @@
   g_free (data->name);
   g_free (data->base_path);
   g_free (data->ext);
-  g_free (data->back_filename);
+  g_strfreev (data->backs);
   g_free (data);
 }
 
@@ -201,10 +203,27 @@
 }
 
 static gboolean
-pysol_config_txt_parse_line_4 (PySolConfigTxtData *data,
-                               const char *line)
+pysol_config_txt_parse_line_4_and_5 (PySolConfigTxtData *data,
+                                     const char *line4,
+                                     const char *line5)
 {
-  data->back_filename = g_strstrip (g_strdup (line));
+  guint i;
+
+  data->backs = g_strsplit (line5, ";", -1);
+  if (!data->backs)
+    return FALSE;
+  data->n_backs = g_strv_length (data->backs);
+  if (data->n_backs < 1)
+    return FALSE;
+  for (i = 0; i < data->n_backs; ++i)
+    g_strstrip (data->backs[i]);
+
+  /* Get the index of the default back (specified in line[4]) */
+  data->default_back_index = 0;
+  for (i = 0; i < data->n_backs; ++i)
+    if (strcmp (data->backs[i], line4) == 0)
+      data->default_back_index = i;
+
   return TRUE;
 }
 
@@ -235,8 +254,7 @@
       !pysol_config_txt_parse_line_1 (pysol_data, g_strstrip (lines[1])) ||
         !pysol_data->name ||
       !pysol_config_txt_parse_line_2 (pysol_data, g_strstrip (lines[2])) ||
-      !pysol_config_txt_parse_line_4 (pysol_data, g_strstrip (lines[4])) ||
-        !pysol_data->back_filename)
+      !pysol_config_txt_parse_line_4_and_5 (pysol_data, g_strstrip (lines[4]), g_strstrip (lines[5])))
     goto out;
 
   pysol_data->base_path = g_build_filename (path, subdir, NULL);
@@ -313,7 +331,7 @@
   if (G_UNLIKELY (card_id == GAMES_CARD_SLOT)) {
     path = g_build_filename (data->base_path, "bottom01.gif" /* FIXMEchpe ext! */, NULL);
   } else if (G_UNLIKELY (card_id == GAMES_CARD_BACK)) {
-    path = g_build_filename (data->base_path, data->back_filename, NULL);
+    path = g_build_filename (data->base_path, data->backs[data->default_back_index], NULL);
   } else {
     static const char suit_char[] = "cdhs";
     int suit, rank;



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